【问题标题】:Linking static and dynamic libraries on LINUX在 LINUX 上链接静态库和动态库
【发布时间】:2017-05-13 07:44:01
【问题描述】:

我正在尝试使用以下语句从不同的库构建可执行文件

g++ -fPIC -O -DUSING_PCH -D_REENTRANT -I"/app1/home1/quickfast/boost_1_61_0/include/boost-1_61" -I"/app1/home1/quickfast/boost_1_61_0/." -I"../../src" -I"../src/Examples" -I"/app1/home1/quickfast/boost_1_61_0/include" -L"." -L"/app1/home1/quickfast/boost_1_61_0/stage/lib" -L/app1/home1/quickfast/quickfast-master/lib -l"QuickFAST" -l"boost_thread-gcc44-mt-1_61" -l"boost_system-gcc44-mt-1_61" -l"boost_filesystem-gcc44-mt-1_61" -l"boost_unit_test_framework-gcc44-mt-1_61" -static -ldl -lpthread -o "../../bin/testSequences"

上面的编译语句包含很多库,有动态库(.so 文件)和静态库(.a 文件)。例如,库 boost_system-gcc44-mt-1_61 在系统中以 libboost_system-gcc44-mt-1_61.so 和 libboost_system-gcc44-mt-1_61.a 的形式存在。我想要的是在编译时只选择动态库(.so 文件)而忽略静态库。谁能指导一下。

【问题讨论】:

    标签: linux compilation g++


    【解决方案1】:

    您告诉它使用-static link option 来获取静态库。如果您删除它,它可能会按您的预期工作。

    【讨论】:

    • 是的,我的意思是-static 并编辑了答案以反映这一点。谢谢@MikeKinghan。
    猜你喜欢
    • 2011-09-09
    • 1970-01-01
    • 1970-01-01
    • 2010-09-15
    • 1970-01-01
    • 1970-01-01
    • 2018-01-23
    • 2011-03-16
    • 1970-01-01
    相关资源
    最近更新 更多