[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Caffe / ITP / FTBFS] undefined reference to `XXX` issue



Hi all,

I'm working on packaging Caffe[1], a deep learning framework.
Now the packaging is done and I'm solving its FTBFS issue,
which is the only blocker for ITP process. However I have trouble
solving this FTBFS issue, so post a message for help.

Packaging work is stored at [2].
According to my README.Debian, two caffe software suites should be
compiled. One of them is "caffe-cpu", which is free of FTBFS.
Well, the package suite really in trouble is "caffe-cuda", so let's
ignore things about "caffe-cpu".

In my fuzzy memory, 1 month ago "caffe-cuda" passed the build
on a Debian testing machine (wich gcc-4.9 and CUDA 6.5 
from experimental), but at the same time it FTBFS on DeboMatic-amd64.
Now CUDA 6.5 transition is done, and the FTBFS emerges on my
Debian Sid system.

The exact reason of FTBFS is things like e.g.:

```
/usr/include/glog/logging.h:672: undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
CMakeFiles/caffe.bin.dir/caffe.cpp.o: In function `std::string* google::MakeCheckOpString<float, int>(float const&, int const&, char const*)':
/usr/include/glog/logging.h:672: undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
../lib/libcaffe.so.0: undefined reference to `google::protobuf::Message::InitializationErrorString() const'
../lib/libcaffe.so.0: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
../lib/libcaffe.so.0: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)'
```

and the corresponding compiling command line is:

```
cd /tmp/caffe/caffe_cuda_build/tools && /usr/bin/cmake -E cmake_link_script CMakeFiles/caffe.bin.dir/link.txt --verbose=1
/usr/bin/g++-4.9   -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2  -fPIC -Wall -Wno-sign-compare -Wno-uninitialized -O3 -DNDEBUG   -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed CMakeFiles/caffe.bin.dir/caffe.cpp.o  -o caffe -rdynamic ../lib/libcaffe.so.0 ../lib/libproto.a -Wl,--start-group -lboost_system -lboost_thread -lpthread -lpthread -lglog -lgflags -lprotobuf /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5_hl.so /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so -lpthread -lpthread -lglog -lgflags -lprotobuf /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5_hl.so /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so -lz -ldl -lm -llmdb -lleveldb -lsnappy -lcudart -lcurand -lcublas /usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.9 -lopenblas -lpython2.7 -lboost_python -Wl,--end-group
```

For full buildlog see [3]. the build platform is Debian Sid +
gcc 4.9 + CUDA 6.5 . (CUDA 6.5 refuses to work with gcc > 4.9)

I've tried several measures to handle this "undefined reference issue" however none
of them works, I'll list them FYI:
(I'm quite sure those symbols in need is indeed included in command line)

1. strip all harden flags and all optimize flags. such as deleting args introduced by 
   hardening=+all, and deleting -O2 ... etc.
   [no difference at all]

2. enclose libs between "-Wl,--start-group" and "-Wl,--end-group" 
   [no difference at all]

3. randomly exchange the order of libs between "-Wl,--start-group" and "-Wl,--end-group"
   [error message differs but is still undefined reference]

And here are some notable points:

1. I'm doing linking with gcc/g++ 4.9 on libXXXv5 libraries.
   However when my caffe-cuda build succeed on testing machine (gcc-4.9 + CUDA 6.5),
   gcc is linking ELFs against libXXX rather than libXXXv5.
   I don't know if gcc-5 libs is root of trouble.

2. Caffe build under ArchLinux hardly fails.
   GCC 5.1 + CUDA 7.0 [ok]
   GCC 5.2 + CUDA 7.5 [ok] (freshly built yesterday)

   While under Debian (I have built Caffe many many times so memory is a bit fuzzy)
   GCC 4.4 + CUDA 6.0 + no_v5libs [OK, then GCC 4.4 was removed from Sid] (fuzzy memory)
   GCC 4.8 + CUDA 6.0 + no_v5libs  [if it succeed I won't struggle for so long ]
   GCC 4.9 + CUDA 6.0 + no_v5libs [if it succeed I won't struggle for so long ]
   GCC 5.1 + CUDA 6.0 + no_v5libs [CUDA refuse to work with gcc > 4.9 ]
   GCC 4.8 + CUDA 6.5 + v5libs [Fail] (fuzzy memory)
   GCC 4.9 + CUDA 6.5 + v5libs [ Fail with undefined reference, CURRENT ]
   GCC 5.2 + CUDA 6.5 + v5libs [CUDA refuse to work with gcc > 4.9]

   While the caffe-cpu
   GCC 4.8 / 4.9 / 5.1 / 5.2 [ all success ] 

3. libcaffe.so depends on glog, gflags and [...]
   In the failed compiling command line, the output ELF file "caffe"
   should be linked to libcaffe.so and glog, gflags and [...]

In summary, I've nearly ran out of means.
And I'm thinking if I should temporarily comment caffe-cuda out,
letting caffe-cpu work first, and wait for a day when caffe-cuda can pass the build.

Any comment is appreciated.
Thank you all. :-)

[1] http://caffe.berkeleyvision.org/
[2] http://anonscm.debian.org/cgit/debian-science/packages/caffe.git/
[3] https://github.com/CDLuminate/asdf/blob/master/caffe_0.9999~rc2%2B20150925-g674b349-1_amd64.build

-- 
 .''`.                                               Lumin
: :' :                         
`. `'   
  `-    638B C75E C1E5 C589 067E  35DE 6264 5EB3 5F68 6A8A

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: