[英]Linker error with POSIX-Threads
I use Dev-C++ 5.5.3.我使用 Dev-C++ 5.5.3。 The linker reports me this error...why?
链接器向我报告了这个错误......为什么?
Why?为什么?
The pthread library is not compatible with Windows. pthread 库与 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
称为 pthreads-win32 ,您也可以尝试
std::thread
但您的代码似乎主要是c
所以最好坚持pthread
Just downloaded Dev-C++ and checked, mingw does include the header files for pthread
but don't let this confuse you.刚刚下载 Dev-C++ 并检查,mingw 确实包含
pthread
的头文件,但不要让这让您感到困惑。 Pthread is not compatible with Windows, so the implementation will not link. Pthread 与 Windows 不兼容,因此实现将不会链接。
Check the Tools -> Compiler Options -> Directories and add the proper directories for your library pthread win32.检查工具 -> 编译器选项 -> 目录并为您的库 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.然后在 Tools -> Compiler Options -> General 中为您的库添加命令,例如 -llibpthread-win32 或您为系统上的 lib 安装的名称。
std::thread
all over the programstd::thread
怎么办Just check that the version of your mingw for C++11 compatibility by adding the command -std=c++11 to your compiler.只需通过向编译器添加命令 -std=c++11 来检查您的 mingw 版本是否与 C++11 兼容。 I suggest the newest version of g++ 4.8 since it includes the tool thread sanitizer.
我建议使用最新版本的 g++ 4.8,因为它包含工具线程消毒器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.