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

前端 未结 2 1080
说谎
说谎 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:42

    Regarding your edit: Put "-Wl,--no-whole-archive" at the end of the link command you're running. That fixed it for me.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题