其中-whole-archive和-no-whole-存档传递给链接器。 当我做相当于Mac的时候:
g ++ -fpic -shared -Wl,-whole-archive somelib。 a -Wl,-no-whole-archive -o somelib.dylibld失败并显示错误:
ld:未知选项:-whole-archive似乎OSX上的ld与GNU ld不同。如何修改上述命令,以便获得所需的结果?
提前谢谢!
解决方案我发现我的问题的解决方案:
g ++ -fpic -shared - Wl,-all_load somelib.a -Wl,-noall_load -o somelib.dylib所需的参数是-all_load和-noall_load。
Suppose I have a third party library called somelib.a on a Mac running Mountain Lion with Xcode 4.4 installed. I want to get a dynamic library out of it called somelib.dylib. An appropriate Linux command would be:
g++ -fpic -shared -Wl,-whole-archive somelib.a -Wl,-no-whole-archive -o somelib.sowhere -whole-archive and -no-whole-archive are passed to the linker. When I do the equivalent for Mac:
g++ -fpic -shared -Wl,-whole-archive somelib.a -Wl,-no-whole-archive -o somelib.dylibld fails with an error:
ld: unknown option: -whole-archiveIt seems that the ld on OSX is different from GNU ld. How do I have to modify above command so I will get the desired result?
Thank you in advance!
解决方案I found out the solution to my problem:
g++ -fpic -shared -Wl,-all_load somelib.a -Wl,-noall_load -o somelib.dylibThe required arguments are -all_load and -noall_load.
更多推荐
OSX:如何将静态库转换为动态库?
发布评论