Link a static library to a shared one during build?

后端 未结 2 1469
無奈伤痛
無奈伤痛 2021-02-02 13:45

I have a problem building a shared library with GCC/Linux. Currently this shared library is created with GCC/libtool option \"-shared\" and everything is fine.

Now there

2条回答
  •  有刺的猬
    2021-02-02 14:06

    You only need the --whole-archive parameter to force the linker to include the library, but it should be able to infer its own needs from unmatched symbols.

    Ensure that any static libraries on the command-line come after their dependent object-files e.g.:

    g++ -Wl,-E -g -pipe -O2 -pipe -fPIC  myobjectfile.o mystaticlibrary.a -shared -o mylib.so
    

提交回复
热议问题