caffe2 icon indicating copy to clipboard operation
caffe2 copied to clipboard

The error of the compling, like"libCaffe2_CPU.so:对‘google::protobuf::io::CodedInputStream::PushLimit(int)’未定义的引用"

Open wuzhijiexia opened this issue 9 years ago • 12 comments

The libs of protobuf were placed on the default path(/usr/local/lib), the version was 3.1.0. After the operation "cmake ../", the value of PROTOBUF_LIBRARY is "/usr/local/lib/libprotobuf.so" in the file CmakeCache.txt. According to it, I thinks caffe2 should can link to the protobuf libs. But there are problems about the link of the protobuf libs. image 10 I hope you can give me some messages to help me.

wuzhijiexia avatar Feb 14 '17 10:02 wuzhijiexia

Could you clean the cmake directory, do

cmake -DCMAKE_VERBOSE_MAKEFILE=1 [your other cmake args]

and then make? A paste of the output would then give us the build string.

Yangqing avatar Feb 14 '17 17:02 Yangqing

make-j32.txt

The partial content: /usr/bin/c++ -std=c++11 -fPIC -Wno-narrowing -O3 -DNDEBUG CMakeFiles/init_test.dir/core/init_test.cc.o -o binaries/init_test -rdynamic libCaffe2_CPU.so -lpthread /usr/local/lib/libglog.so /usr/local/lib/libgflags.so -llmdb -lleveldb -lsnappy -lopencv_imgproc -lopencv_highgui -lopencv_core /opt/intel/compilers_and_libraries_2017.1.132/linux/mpi/intel64/lib/libmpicxx.so /opt/intel/compilers_and_libraries_2017.1.132/linux/mpi/intel64/lib/libmpifort.so /opt/intel/compilers_and_libraries_2017.1.132/linux/mpi/intel64/lib/release_mt/libmpi.so /opt/intel/compilers_and_libraries_2017.1.132/linux/mpi/intel64/lib/libmpigi.a -ldl -lrt -lpthread ../third_party/googletest/googlemock/gtest/libgtest_main.so ../third_party/googletest/googlemock/gtest/libgtest.so -lpthread -Wl,-rpath,/home/zhengwu/caffe2/build/caffe2:/usr/local/lib:/opt/intel/compilers_and_libraries_2017.1.132/linux/mpi/intel64/lib:/opt/intel/compilers_and_libraries_2017.1.132/linux/mpi/intel64/lib/release_mt:/home/zhengwu/caffe2/build/third_party/googletest/googlemock/gtest: libCaffe2_CPU.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteInt64(int, long, google::protobuf::io::CodedOutputStream*)'

When creating the dynamic library libCaffe2_CPU.so, there is not the linking of the protobuf-libs.

wuzhijiexia avatar Feb 15 '17 03:02 wuzhijiexia

Very interesting - what cmake version are you using?

@bwasti I suspect this is a similar issue to what we encountered - cmake might have changed its internal Protobuf vs PROTOBUF naming convention.

Yangqing avatar Feb 15 '17 04:02 Yangqing

The cmake version which I am using is 2.8.12.2.

wuzhijiexia avatar Feb 15 '17 05:02 wuzhijiexia

I just realized - are you building with Cygwin / mingw on a Windows machine? That might trigger the local build of protobuf which is not intended. Windows support is currently flaky.

Yangqing avatar Feb 15 '17 05:02 Yangqing

Do I need the newer version cmake?

wuzhijiexia avatar Feb 15 '17 05:02 wuzhijiexia

For now, if you are building on windows, try to remove "OR WIN32" here and see if fix your problem:

https://github.com/caffe2/caffe2/blob/master/cmake/ProtoBuf.cmake#L4

Yangqing avatar Feb 15 '17 05:02 Yangqing

I am building on Linux.

wuzhijiexia avatar Feb 15 '17 05:02 wuzhijiexia

It looks as though CMake 2.8 sets PROTOBUF_LIBRARY (https://www.apt-browse.org/browse/ubuntu/trusty/main/all/cmake-data/2.8.12.2-0ubuntu3/file/usr/share/cmake-2.8/Modules/FindProtobuf.cmake line 226) whereas the later version of CMake sets Protobuf_LIBRARIES / PROTOBUF_LIBRARIES (https://github.com/Kitware/CMake/blob/master/Modules/FindProtobuf.cmake#L415).

This may fix it https://github.com/caffe2/caffe2/pull/152

bwasti avatar Feb 15 '17 16:02 bwasti

Thanks very much, @Yangqing and @bwasti . The problem has solved according to update ProtoBuf.cmake.

wuzhijiexia avatar Feb 16 '17 01:02 wuzhijiexia

@wuzhijiexia hello,I miss the same problem. how to update ProtoBuf.cmake?thanks

yanxp avatar Apr 22 '17 12:04 yanxp

It looks as though CMake 2.8 sets PROTOBUF_LIBRARY (https://www.apt-browse.org/browse/ubuntu/trusty/main/all/cmake-data/2.8.12.2-0ubuntu3/file/usr/share/cmake-2.8/Modules/FindProtobuf.cmake line 226) whereas the later version of CMake sets Protobuf_LIBRARIES / PROTOBUF_LIBRARIES (https://github.com/Kitware/CMake/blob/master/Modules/FindProtobuf.cmake#L415).

This may fix it #152

wuzhijiexia avatar Apr 22 '17 14:04 wuzhijiexia