【问题标题】:Boost with eclipse cannot find thread library使用eclipse Boost 找不到线程库
【发布时间】:2015-01-21 12:16:24
【问题描述】:

我已经下载并构建了 boost 库

bootstrap mingw 

b2 toolset=gcc

这些库是在

中创建的
C:\Boost\boost_1_57_0\stage\lib

在 Eclipse 中我已将此目录添加为库路径

并添加库libboost_thread-mgw49-mt-1_57,最后带有和不带有.a。

g++ 行看起来像

g++ "-LC:\\Boost\\boost_1_57_0\\stage\\lib" -o MyThread.exe main.o MyThread.o -llibboost_thread-mgw49-mt-1_57 

我收到错误消息

ld.exe: cannot find -llibboost_thread-mgw49-mt-1_57 collect2.exe: error: ld returned 1 exit status

如果我添加.a,它会按预期附加到错误消息中。

我做错了什么?

【问题讨论】:

    标签: c++ eclipse boost


    【解决方案1】:

    指定不带 lib 前缀(这是 UNIX 约定)的库:

    g++ "-LC:\Boost\boost_1_57_0\stage\lib" -pthread -o MyThread.exe main.o MyThread.o -libboost_thread-mgw49-mt-1_57 
    

    甚至有可能(借助一些标准约定符号链接)您可以直接说 -lboost_thread

    PS也别忘了使用-pthread

    【讨论】:

    • 谢谢,删除库确实有效,感谢您的帮助。
    猜你喜欢
    • 2019-12-29
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-06
    • 2011-12-26
    相关资源
    最近更新 更多