问题描述
我试图编译一个简单的c ++程序,在eclipse kepler / mingw 4.8.1和win32上使用std :: thread。我希望在Windows开发多年后的某个时候将开发移动到linux。
#includetest.h
#include< thread>
#include< algorithm>
int main()
{
Test :: CreateInstance();
std :: thread(
[&]()
{
Test :: I() - > Output2();
}
);
Test :: DestroyInstance();
return 0;
}
忽略测试的目的(这是一个单例,一旦我得到std ::线程工作!)
我在Eclipse中设置的g ++编译器设置是:
-c -fmessage-length = 0 -std = c ++ 0x -Wc ++ 0x-compat
我定义的预处理器符号是:
__GXX_EXPERIMENTAL_CXX0X__
建筑物抱怨std :: thread不是std的成员:
10:30:13 ****增量配置构建项目测试的调试****
信息:Internal Builder用于build
g ++ -D__GXX_EXPERIMENTAL_CXX0X__ -O0 -g3 -Wall -c -fmessage-length = 0 -std = c ++ 0x -Wc ++ 0x-compat -o main.o.. \\main。 cpp
..\main.cpp:在函数'int main()':
..\main.cpp:11:2:error:'thread'不是' std'
std :: thread(
^
Plain MinGW不能支持 您可以在找到安装程序,但您也可以尝试替换整个 I'm trying to compile a simple c++ program that uses std::thread on eclipse kepler / mingw 4.8.1 and win32. I hope to move development to linux at some point after many years on windows development. Ignoring the purpose of test (it's a singleton that just produces some output that I will expand upon, once I get the std::thread working!) The g++ compiler settings I've set in Eclipse are: And the preprocessor symbol I have defined is: Building complains that std::thread is not a member of std: Can someone suggest what I might be missing to get this compiling correctly? Plain MinGW cannot support You can find an installer here, but you can also try just replacing the whole 这篇关于std :: thread不是使用Eclipse Kepler MinGW的命名空间std的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! std :: thread
。您将需要使用启用了posix线程的MinGW-w64工具链(如Qt 5附带的工具链),以便libstdc ++公开
< thread>
< mutex>
和< future>
功能。
mingw
工具链根文件夹与。你可以选择32位或64位,记得要选择 threads-posix
如果你想玩 std :: thread
和朋友。除了您已经拥有的编译器选项之外,不需要特殊的编译器选项。如果您不需要GCC 4.6兼容性,我建议使用 -std = c ++ 11
。#include "test.h"
#include <thread>
#include <algorithm>
int main()
{
Test::CreateInstance();
std::thread(
[&]()
{
Test::I()->Output2();
}
);
Test::DestroyInstance();
return 0;
}
-c -fmessage-length=0 -std=c++0x -Wc++0x-compat
__GXX_EXPERIMENTAL_CXX0X__
10:30:13 **** Incremental Build of configuration Debug for project test ****
Info: Internal Builder is used for build
g++ -D__GXX_EXPERIMENTAL_CXX0X__ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -Wc++0x-compat -o main.o "..\\main.cpp"
..\main.cpp: In function 'int main()':
..\main.cpp:11:2: error: 'thread' is not a member of 'std'
std::thread(
^
std::thread
. You will need to use a MinGW-w64 toolchain (such as those shipped with Qt 5) that has "posix" threading enabled, so that libstdc++ exposes the <thread>
, <mutex>
and <future>
functionality.mingw
toolchain root folder with one of these packages. You can choose 32- or 64-bit, remember to select threads-posix
if you want to play with std::thread
and friends. No special compiler options other than the ones you already have are needed. I do suggest using -std=c++11
if you don't need GCC 4.6 compatibility.