Can't use threads

Pages: 1234
Project->Build Options->Linker Settings->Link Libraries->Add:

<Nuwen MinGW install directory>\lib\libboost_thread.a
What if I'm not using a project, but just plain source files?
Assuming that the Nuwen MinGW build is in "C:\MinGW" and the (only) source file is "myfile.cc"

1
2
3
4
5
6
7
> C:\MingW\set_distro_paths
...
> g++ -O3 -std=c++11 -pedantic -pedantic-errors -Wall -Wextra -Werror -I"C:\MinGW\include" -c myfile.cc -o myfile.o
...
> g++ -L"MinGW\lib" -o myfile.exe myfile.o -lboost_thread
...
> myfile
Theese are the linker errors when using projects:
The linker wrote:
In function `main':
[Linker error] C:\Users\Vilim\Desktop\New folder/main.cpp:10: undefined reference to `__imp___ZN5boost6thread4joinEv'1
In function `thread<main(int, char**)::<lambda()> >':
[Linker error] C:/Program Files/MinGW/lib/gcc/mingw32/4.7.0/include/c++/myBoost/boost/thread/detail/thread.hpp:186: undefined reference to `__imp___ZN5boost6thread12start_threadEv'2
In function `_ZN5boost6threadD1Ev'3:
[Linker error] C:/Program Files/MinGW/lib/gcc/mingw32/4.7.0/include/c++/myBoost/boost/thread/detail/thread.hpp:174: undefined reference to `__imp___ZN5boost6thread6detachEv' 4
C:\Users\Vilim\Desktop\New folder\collect2.exe [Error] ld returned 1 exit status
C:\Users\Vilim\Desktop\New folder\Makefile.win [Error] [ThreadsTest.exe] Error 1 (if this is the only error: please check your library includes)

1: boost::thread::join()
2: boost::thread::start_thread()
3: boost::thread::~thread()
4: boost::thread::detach()
Last edited on
@JLBorges it still can't find them!
Compiler options: -std=c++11 -fpermissive -Wall -Wextra -I"C:\Program Files\Novi_MinGW\MinGW\include"
Linker options: -static-libstdc++ -static-libgcc -L"C:\Program Files\Novi_MinGW\MinGW\lib" -libboost_thread -libboost_system -libboost_thread
Linker options:

either: -L"C:\Program Files\Novi_MinGW\MinGW\lib" -lboost_thread myfile.o

or: C:\Program Files\Novi_MinGW\MinGW\lib\libboost_thread.a myfile.o


-libboost_thread lloks for the library libibboost_thread.a

The only difference between using an -l option and specifying a file name is that -l surrounds library with `lib' and `.a' and searches several directories.
- http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
IT WORKS!!!!!!!!
Thanks to everyone who helped me soo much!
Topic archived. No new replies allowed.
Pages: 1234