Outline of the problem:
Files (all in /vol/cuma/sandbox):
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
In the first step, I have built the libb.so (No errors):
g++ -Wall -fPIC -c b.cpp
g++ -shared -W1,-soname,libb.so.1 -o libb.so.1.0 b.o
ln -sf /vol/cuma/sandbox/libb.so.1.0 /vol/cuma/sandbox/libb.so
ln -sf /vol/cuma/sandbox/libb.so.1.0 /vol/cuma/sandbox/libb.so.1
In the second step, the liba.so (No errors):
g++ -Wall -fPIC -c a.cpp
g++ -shared -W1,-soname,liba.so.1 -o liba.so.1.0 a.o -L/vol/cuma/sandbox -lb
ln -sf /vol/cuma/sandbox/liba.so.1.0 /vol/cuma/sandbox/liba.so
ln -sf /vol/cuma/sandbox/liba.so.1.0 /vol/cuma/sandbox/liba.so.1
At the end, the atest which gives the error
g++ -Wall -L/vol/cuma/sandbox atest.cpp -la -lb -o atest
error: /vol/cuma/sandbox/liba.so: undefined reference to `bf01(int)'
On the beginning I have linked the libb.so only building the liba.so (it was my goal). I am startled that the direct linking during atest.cpp compilation gives the same error: undefined reference to bf01.
Would you be so kind and point where I am making error.