Carsten Fuchs wrote:
Hello all,I've written an executable and a .so shared library, and the executable dlopen()s the shared library during runtime. The executable has been linked with g++ ... -lcfsLib -Wl,-rpath,. -Wl,--export-dynamic where the libcfsLib.a contains symbols that are supposed to be referenced by the dlopen()ed shared library later. However, my call to dlopen() returns with an error message about an undefined symbol that I would have expected to be provided by libcfsLib.a. I guess what happens is that when the linker links the executable, it removes all symbols from libcfsLib.a that are unused by the executable. As a consequence, when dlopen() is called with the shared object that needs the previously removed symbol in the executable, it is not found. grep'ing the output of nm for the executable doesn't list the missing symbol either. Thus, is there a way to make the linker *not* remove some or all unused symbols somehow? Isn't that the supposed purpose of the --export-dynamic parameter?
Hi Carsten, I guess the ld switch "--whole-archive" might be what you need. So you have to make sure that the linker gets called with the sequence ... --whole-archive -lcfsLib --no-whole-archive ... which sets the switch just for the one library but not for the others. I'm not quite sure how to do it within the command line for compiling and linking (since I use the switch in a makefile which has separate calls for compiling and linking). Cheers Maett _______________________________________________ help-gplusplus mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gplusplus
