简体   繁体   中英

Linker error with POSIX-Threads

I use Dev-C++ 5.5.3. The linker reports me this error...why?

在此处输入图片说明

Why?

The pthread library is not compatible with Windows. Don't worry, there is a library for that. Called pthreads-win32 , you could also try std::thread but your code seems mostly c so better stick to pthread

Just downloaded Dev-C++ and checked, mingw does include the header files for pthread but don't let this confuse you. Pthread is not compatible with Windows, so the implementation will not link.

How to link pthread win32?

Check the Tools -> Compiler Options -> Directories and add the proper directories for your library pthread win32.

And then add the command in Tools -> Compiler Options -> General for your library like this -llibpthread-win32 or the name you installed for the lib on your system.

What if I want to go C++ and std::thread all over the program

Just check that the version of your mingw for C++11 compatibility by adding the command -std=c++11 to your compiler. I suggest the newest version of g++ 4.8 since it includes the tool thread sanitizer.

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