【问题标题】:mingw 5 std::this_thread not definedmingw 5 std::this_thread 未定义
【发布时间】:2015-02-24 00:10:34
【问题描述】:

您好,有没有人尝试使用 header 支持 mingw w64?

main.cpp: In function 'int main()':
main.cpp:9:10: error: 'std::this_thread' has not been declared
std::this_thread::sleep_for( dura );
      ^

我通过以下简单测试得到了上述错误

#include <iostream>
#include <chrono> 
#include <thread>

int main()
{ 
 std::cout << "Hello waiter" << std::endl;
 std::chrono::milliseconds dura( 2000 );
 std::this_thread::sleep_for( dura );
 std::cout << "Waited 2000 ms\n";
}

我想使用此处指定的最新 N3653 和 N3651 https://gcc.gnu.org/projects/cxx1y.html,当然还有线程支持标头,使用此处找到的某人构建 http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/dongsheng-daily/5.0/ 而且我的 c++config.h _GLIBCXX_USE_NANOSLEEP 没有定义,知道吗?

[编辑] 我意识到我的线程模型是:win32 而不是 posix one。如何启用 posix 支持?

【问题讨论】:

标签: c++ c++11 mingw c++14


【解决方案1】:

您可以对 i686-w64-mingw-g++ 使用 update-alternatives 并将其从 i686-w64-mingw-g++-win32 设置为 i686-w64-mingw-g++-posix

或者你可以只使用i686-w64-mingw-g++-posix 来编译。 还有其他版本,所以在这种情况下,您可以改用 64 位编译器并将 -posix 附加到它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-24
    • 2011-05-25
    • 1970-01-01
    • 1970-01-01
    • 2019-07-29
    • 2015-02-13
    • 2020-10-19
    • 1970-01-01
    相关资源
    最近更新 更多