I\'m compiling some shared objects file into an archive.a
:
$ g++ -c -Iinclude/ -fPIC -O0 -o object1.o source1.cpp
$ g++ -c -Iinclude/ -fPIC -O0
Regarding your edit: Put "-Wl,--no-whole-archive" at the end of the link command you're running. That fixed it for me.
symbols/object files in .a files that's not used, will be discarded by the linker.
Use -Wl,--whole-archive
for the linking to include the entire .a file
Edit, you'll need to add -Wl,--no-whole-archive
after you specify your library as well, so the whole thing will be -Wl,--whole-archive archive1.a archive2.a -Wl,--no-whole-archive