【问题标题】:std::thread is not being found on gcc-8.2.2 with flag option -m32. I'm using mingw在带有标志选项 -m32 的 gcc-8.2.2 上找不到 std::thread。我正在使用 mingw
【发布时间】:2019-04-16 16:14:17
【问题描述】:

我试图为一个学校项目编译一个 cpp 程序。它对图形使用 libbgi,适用于 32 位目标。对于这个项目,我想用 std::thread 添加一些多线程,但编译器说我找不到 std::thread。

我尝试了一个低版本的编译器,支持 c++11。


#include <iostream>
#include <thread>

int main(){
    std::thread t([](){
             std::cout << "Hello\n";
        }
    );
    t.join();
}

这个程序用 -m64 可以很好地编译,但不能用 -m32。

【问题讨论】:

  • 欢迎来到 Stack Overflow。文本图像在小屏幕上无法访问、搜索或轻松阅读。请edit 问题并用图片中包含的文本来扩充或替换图片。可以使用问题编辑器中的功能适当地格式化文本。

标签: c++ multithreading gcc mingw


【解决方案1】:

我相信您可能需要与pthread 链接并使用c++0x

g++ -std=c++0x -m32 main.cpp -pthread -o main

我重新创建了您的错误,并使用这些标志解决了它。

【讨论】:

    猜你喜欢
    • 2014-04-13
    • 2018-01-07
    • 2021-01-04
    • 1970-01-01
    • 2021-07-09
    • 2022-01-06
    • 1970-01-01
    • 2017-09-22
    相关资源
    最近更新 更多