线程创建失败
MinGW-w64 Thread Creation Failure
解析:在杂项链接选项中传递"-static" ——或分辨率:下载此mingw版本http://sourceforge.net/projects/mingwbuilds/?source=dlp
我正在使用带有MinGW-w64工具链的Eclipse。我的GCC版本是4.8
我想创建一个由2个线程组成的应用程序。我已经尝试过在我的实际应用中实现这个。因此,它没有工作,我决定做一个新的测试应用程序。
源(main.cpp):
#include <iostream>
#include <thread>
using namespace std;
void test() {
cout << "works.." << endl;
}
int main() {
thread t(test);
t.join();
return 0;
}
构建过程:
21:19:51 **** Build of configuration Debug for project Test ****
make all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -std=gnu++11 -O0 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
Finished building: ../main.cpp
Building target: Test.exe
Invoking: MinGW C++ Linker
g++ -o "Test.exe" ./main.o -lpthread -lwinpthread -pthread -lpthread
Finished building target: Test.exe
21:19:53 Build Finished (took 1s.863ms)
当运行时,我得到以下错误:
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
顺便说一句:许多-pthread等命令来自于几次尝试使其工作。我运行的是winvista 32位
如果有人知道如何解决我的问题,我真的很感激。提前感谢!查看本地win32 std::thread实现,可以添加到任何c++ 11版本的MinGW中:https://github.com/meganz/mingw-std-threads
相关文章:
- 链接到自行创建的dll失败
- C/C++:socket() 创建在循环中失败,打开的文件太多
- 创建服务失败0x6f7存根收到错误数据
- 两个线程一个使用流 Api,另一个线程创建文件失败并出现错误ERROR_SHARING_VIOLATION
- 使用 SQLConfig数据源创建 SQL Server DSN 失败:关键字-值对无效
- 创建进程 API 失败,在窗口 122 上出现错误代码 10
- fopen 在创建大量文件后因 EFBIG "File too large" 而失败
- C++从 std::string 创建 CString 失败
- 创建进程失败,意外错误
- lib OSMesa 屏幕外上下文创建在C++中失败,但仅在静态链接时失败
- C++ - 创建进程失败代码 2
- C++ Mingw32 创建进程() 失败,错误代码 2:系统找不到指定的文件
- 创建 ./config.data 在编译 Mozilla Firefox 时失败
- Qt OpenGL帧缓冲在一台PC上创建,但在另一台PC上失败
- 视觉C++窗口创建失败
- 用户创建程序失败
- 使用创建进程函数创建"dir"命令失败,错误代码为 2
- Vulkan-加载扩展时实例创建失败
- OpenGL 创建渲染上下文失败
- 创建对象时调试断言失败