Reputation: 409
I have shared library which is dependent on a few static libraries which includes zlib etc. When I am building my shared library with the dependent static libraries with g++ (cent os 6.3) it is getting compiled fine. Now when I try to use my shared library on a test project I am getting a lot of unresolved errors. What I am doing wrong ?
g++ -L/usr/local/lib -L/home/de.../workspace/libtest/Debug -o "mytest" ./src/mytest.o -ltest
/home/de.../workspace/libtest/Debug/libtest.so: undefined reference to `BZ2_bzCompressEnd'
collect2: ld returned 1 exit status
Upvotes: 1
Views: 1320
Reputation: 47082
The error makes it look like you need to link against bzip2 as well:
g++ -L/usr/local/lib -L/home/de.../workspace/libtest/Debug -o "mytest" ./src/mytest.o -ltest -lbz2
You do need to be careful about linking static libraries into a shared one, but you're seeing this error because you need to link in the remaining libraries.
Upvotes: 1