我已经下载并构建了 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/