I am trying link Caffe static library (libcaffe.a) to use it in my project, but I want to link it using the command -Wl,--whole-archive. The issue is that after ldd -d mylib.so it shows a lot of undefined symbol from Caffe, as if the libcaffe.a wasn't really linked to mylib.so.
Steps to reproduce
Create a docker container with Ubuntu 18.04 minimal
The C compiler identification is GNU 7.4.0
The CXX compiler identification is GNU 7.4.0
Check for working C compiler: /usr/bin/cc
Check for working C compiler: /usr/bin/cc -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: /usr/bin/c++
Check for working CXX compiler: /usr/bin/c++ -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Looking for pthread.h
Looking for pthread.h - found
Looking for pthread_create
Looking for pthread_create - not found
Looking for pthread_create in pthreads
Looking for pthread_create in pthreads - not found
Looking for pthread_create in pthread
Looking for pthread_create in pthread - found
Found Threads: TRUE
Boost version: 1.65.1
Found the following Boost libraries:
system
thread
filesystem
chrono
date_time
atomic
Found GFlags: /usr/include
Found gflags (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libgflags.so)
Found Glog: /usr/include
Found glog (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libglog.so)
Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread (found version "3.0.0")
Found PROTOBUF Compiler: /usr/bin/protoc
HDF5: Using hdf5 compiler wrapper to determine C configuration
HDF5: Using hdf5 compiler wrapper to determine CXX configuration
Found HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_cpp.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so (found version "1.10.0.1") found components: HL
CUDA is disabled. Building without it...
Found OpenBLAS libraries: /usr/lib/x86_64-linux-gnu/libopenblas.so
Found OpenBLAS include: /usr/include/x86_64-linux-gnu
Python interface is disabled or not all required dependencies found. Building without it...
Found Git: /usr/bin/git (found version "2.17.1")
******************* Caffe Configuration Summary *******************
General:
Version : 1.0.0
Git : 1.0-dirty
System : Linux
C++ compiler : /usr/bin/c++
Release CXX flags : -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
Debug CXX flags : -g -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
Build type : Release
BUILD_SHARED_LIBS : OFF
BUILD_python : OFF
BUILD_matlab : OFF
BUILD_docs : OFF
CPU_ONLY : ON
USE_OPENCV : OFF
USE_LEVELDB : OFF
USE_LMDB : OFF
USE_NCCL : OFF
ALLOW_LMDB_NOLOCK : OFF
Dependencies:
BLAS : Yes (open)
Boost : Yes (ver. 1.65)
glog : Yes
gflags : Yes
protobuf : Yes (ver. 3.0.0)
CUDA : No
Install:
Install path : /mypath/caffe/build/install
Configuring done
Generating done
Build files have been written to: /mypath/caffe/build
Issue summary
I am trying link Caffe static library (
libcaffe.a
) to use it in my project, but I want to link it using the command-Wl,--whole-archive
. The issue is that afterldd -d mylib.so
it shows a lot ofundefined symbol
from Caffe, as if thelibcaffe.a
wasn't really linked tomylib.so
.Steps to reproduce
Tried solutions
I tried to use another version of gcc/g++, but I found another problem that I've reported here
System configuration
Issue checklist
My CMakeLists.txt to generate
mylib.so
Terminal output after step 8
Terminal output after step 14