samedi 20 septembre 2014

GCC Linker Warning/Error - *.so needed by *.so not found


Vote count:

0




In my case there are 2 .so and an .exe,



A.so

B.so depends on A.so

output.exe depends on B.so


Both A.so and B.so are built fine. However I have this warning (and 3 errors) when building output.exe:



warning: libA.so.1, needed by ../../../out/bin/lib64/libB.so, not found (try using -rpath or -rpath-link)
../lib64/libB.so: undefined reference to 'foo()'


The linker flag of B.so is:


g++ ... -o libB.so.1.0.0 -Wl,-soname,libB.so.1 -L../../out/bin/lib64 -lA


The linker flags of output.exe is:


g++ ... -o Output.exe -Wl,-rpath,'$ORIGIN' -L../../out/bin/lib64 -lB


The warning and error go away if I add -lA to linker flag of output.exe. My question are:



  1. Do I really need to link A.so to the exe? Even I've already linked the A.so to B.so when producing B.so?

  2. Why am I getting undefined reference to foo()? It is a global function in A.so. Declaration:


void foo()


GCC version: 4.7.2


Thank you!



asked 1 min ago

Wilson

124






GCC Linker Warning/Error - *.so needed by *.so not found

Aucun commentaire:

Enregistrer un commentaire