Linking archives (.a) into shared object (.so)

前端 未结 2 1079
说谎
说谎 2020-12-08 05:22

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          


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 05:53

    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

提交回复
热议问题