Hello
Outline of the problem:
Files:
1. a.cpp, a.h, atest.cpp
2. b.cpp, b.h
- file a.cpp is compiled to liba.so
- file b.cpp is compiled to libb.so
- function af01 defined in a.cpp calls the function bf01 defined in b.cpp
- file atest.cpp is compiled to executable program, which calls the af01 function therefore it calls indirectly the bf01 function
During atest.cpp compilation a compiler claims that:
mormegil@devel-1:/vol/cuma/sandbox$ g++ -Wall -L/vol/cuma/sandbox atest.cpp -la -o atest
/vol/cuma/sandbox/liba.so: undefined reference to `bf01(int)'
What is the way of correct compilation of liba.so ?
Up until now I did it in the following manner :
mormegil@devel-1:/vol/cuma/sandbox$ g++ -Wall -fPIC -c a.cpp
mormegil@devel-1:/vol/cuma/sandbox$ g++ -shared -W1,-soname,liba.so.1 -o liba.so.1.0 a.o -L/vol/cuma/sandbox/ -lb
mormegil@devel-1:/vol/cuma/sandbox$ ln -sf /vol/cuma/sandbox/liba.so.1.0 /vol/cuma/sandbox/liba.so
mormegil@devel-1:/vol/cuma/sandbox$ ln -sf /vol/cuma/sandbox/liba.so.1.0 /vol/cuma/sandbox/liba.so.1
and finally :
mormegil@devel-1:/vol/cuma/sandbox$ g++ -Wall -L/vol/cuma/sandbox atest.cpp -la -o atest
If the function af01 doesn't call the bf01 from libb.so the atest compiles and works well.
Best regards
Cuma