0

I have this problem, I am trying to build caffe on debian machine, I will build everything but at the end at linking I get multiple undefined references to google::protobuf::...

I am attaching file with build log, containing error messages (build_caffe.txt). Both libprotobuf-dev and protoc are installled. (output of dpkg -s is in proto.txt)

Here is how I build caffe.

export CXX=g++-4.9
export CC=gcc-4.9
cmake -D CUDA_HOST_COMPILER=/usr/bin/x86_64-linux-gnu-gcc-4.9 -D CUDA_USE_STATIC_CUDA_RUNTIME=OFF ..
make all

Does anyone know a solution for this problem please?

proto.txt

build_caffe.txt

MrAzgra
  • 3
  • 2
  • 3

1 Answers1

0

Looks like your protobuf was compiled using a different version of gcc. Try to remove protobuf from your system and install it from sources, using the same gcc version you would like to use fro Caffe. (/usr/bin/x86_64-linux-gnu-gcc-4.9 according to your command).
EDIT:
If you can't install the updated protobuf, edit $CAFFE_ROOT/cmake/ProtoBuf.cmake and make the following changes:

#find_package( Protobuf REQUIRED ) # 1. Comment out this line
# 2. explicitly define protobuf's directories
set(PROTOBUF_INCLUDE_DIR path_to_protobuf/src/google/protobuf)
set(PROTOBUF_LIBRARIES path_to_where_protobuf_libs_are_built_to)
# 3. Explicitly set the full path to protoc executable
set(PROTOBUF_PROTOC_EXECUTABLE path_to_where_the_new_protoc_executable_is_build_to)
# ... Continue as usual
list(APPEND Caffe_INCLUDE_DIRS PUBLIC ${PROTOBUF_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS PUBLIC ${PROTOBUF_LIBRARIES})
#...
rkellerm
  • 5,362
  • 8
  • 58
  • 95
  • Problem is I am not root on this machine. So I could download protobuf and and build it in my folder. Do you know if I can then specify protobuf location to my folder? – MrAzgra Oct 24 '17 at 08:52
  • If you change cmake/ProtoBuf.cmake and set implicitly PROTOBUF_INCLUDE_DIR and PROTOBUF_LIBRARIES. – rkellerm Oct 24 '17 at 09:35
  • Ok I will try it. Thank you for now. – MrAzgra Oct 24 '17 at 09:55
  • So I built protobuf, passed all tests, but cannot find directories which I would set as PROTOBUF_INCLUDE_DIR and PROTOBUF_LIBRARIES. Is it even possible without running 'make install'? – MrAzgra Oct 24 '17 at 15:28
  • The include path is probably src/google/protobuf/. To find the library path run "find . -name *.so" from protobuf sources directory. The directory where the .so file is in is the library path. – rkellerm Oct 25 '17 at 08:44
  • Yes you were right. Now I tried it with protoc 3.4 but got error 'This file was generated by a newer version of protoc which is', so I will try to get older version of protobuf. – MrAzgra Oct 25 '17 at 22:30
  • What else do I need to add to [Protobuf.cmake](https://pastebin.com/WHA43KZN) file? e.g. if i set path to protoc and protobuf library version 2.6.1. I get warning that Protoc ver. 2.6.1 does not match library version 3.0.0, which was found automatically. (this one is installed on machine and does not work for me.). So how do I stop auto search for library? – MrAzgra Oct 26 '17 at 13:59
  • Yes it helped to find mine version of protobuf. Unfortunately I still get undefined references to protobuf when building caffe. I think there is no solution for this and will move on. – MrAzgra Oct 31 '17 at 12:16