c++ - Boost with eclipse找不到线程库

标签 c++ eclipse boost

我已经下载并构建了 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,它会按预期附加到错误消息中。

我做错了什么?

最佳答案

指定没有 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 

甚至有可能(在一些标准约定符号链接(symbolic link)的帮助下)您可以只说 -lboost_thread

PS 不要忘记也使用-pthread

关于c++ - Boost with eclipse找不到线程库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27093760/

相关文章:

c++ - Boost:如何从现有属性树中获取子树?

c++ - Eclipse CDT - 使用模板默认值时为 "Invalid arguments"

c++ - 如何将模板类限制为仅枚举数据类型除外

c++ - 错误 : too many initializers for const

Android调试问题与eclipse

eclipse - 在 Eclipse Package Explorer 和搜索中更改字体大小

c++ - 如何找出lambda的自动类型参数中的哪些方法?

c++ - 源更改后自动运行测试

java - Eclipse J2EE 预览服务器无法找到已部署的页面

elasticsearch - 在Elasticsearch中搜索词组时应用不同的 boost 值?