简体   繁体   中英

Boost with eclipse cannot find thread library

I have downloaded and build the boost libraries with

bootstrap mingw 

and

b2 toolset=gcc

and the libraries are created in

C:\Boost\boost_1_57_0\stage\lib

In eclipse I have added this directory as a library path

and added the library libboost_thread-mgw49-mt-1_57 with and without the .a on the end.

the g++ line looks like

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

and I get the error message

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

If I add the .a it is appended to the error message as expected.

what am I doing wrong?

Specify the library without the lib prefix (which is the UNIX convention):

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

There's even a chance that (with the help of some standard convention symlinks) you could just say -lboost_thread .

PS Don't forget to use -pthread as well

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM