C++ ';标准:螺纹';在标题'中定义&书信电报;螺纹>';;你忘了'#包括<;螺纹>';?

C++ ';标准:螺纹';在标题'中定义&书信电报;螺纹>';;你忘了'#包括<;螺纹>';?,c++,multithreading,mingw,C++,Multithreading,Mingw,我正在执行以下命令: g++ -std=c++17 -g3 -O3 main.cpp -o program.exe 我不断得到以下编译错误: main.cpp:70:22: error: 'thread' is not a member of 'std' std::vector<std::thread> ThreadVector; ^~~~~~ main.cpp:70:22: note: 'std::thread' is def

我正在执行以下命令:

g++ -std=c++17 -g3 -O3 main.cpp -o program.exe
我不断得到以下编译错误:

main.cpp:70:22: error: 'thread' is not a member of 'std'
     std::vector<std::thread> ThreadVector;
                      ^~~~~~
main.cpp:70:22: note: 'std::thread' is defined in header '<thread>'; did you forget to '#include <thread>'?
main.cpp:39:1:
+#include <thread>

main.cpp:70:22:
     std::vector<std::thread> ThreadVector;
                      ^~~~~~
main.cpp:70:28: error: template argument 1 is invalid
     std::vector<std::thread> ThreadVector;
                            ^
main.cpp:70:28: error: template argument 2 is invalid
不确定我是否能找到这个答案,我一直在这里搜索和寻找,没有直接的解决方案。因此,我希望这能提出一个所有人都能从中受益的解决方案

作为记录,是的,我知道gcc/g++目前不支持

编辑:我的包括,

#include <stdio.h>
#include <getopt.h>
#include <vector>
#include <thread> 

int main(int argc, char **argv)
{
    std::vector<std::thread> ThreadVector;
    return 0;
}
#包括
#包括
#包括
#包括
int main(int argc,字符**argv)
{
std::vector-ThreadVector;
返回0;
}

我们需要。如果不看上面的代码,我们就猜不出你的代码有什么问题。@JohnSmith那么请解释你到底是如何安装MinGW的,因为它并不是在所有情况下都自动提供线程支持。显示的代码没有任何问题,所以您的编译器安装一定有问题。@JohnSmith虽然我不知道,但我认为MinGW发行版不支持开箱即用的线程。我认为您想安装设置了正确选项的mingw-w64或MSYS2。@JohnSmith请记住按照链接问题中的说明设置POSIX线程选项。
#include <stdio.h>
#include <getopt.h>
#include <vector>
#include <thread> 

int main(int argc, char **argv)
{
    std::vector<std::thread> ThreadVector;
    return 0;
}