[英]How can i compile c++ with openmp? (using g++ in windows 10)
我是C ++编程的新手。 openMP中的新功能。 我有这个简单的代码
#include <stdio.h>
#include <omp.h>
int main(int argc, char const *argv[])
{
#pragma omp parallel
printf("This is thread %d out of %d\n", omp_get_thread_num(), omp_get_num_threads());
return 0;
}
当我尝试使用编译时
g++ -fopenmp file_name.cpp
在cmd中,我得到这个错误
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot
find -lpthread collect2.exe: error: ld returned 1 exit status
我使用Windows 10,GCC版本为6.3.0。 我怎样才能解决这个问题? 谢谢
对于MinGW32, 这会有所帮助。
或者,您可以使用TDM-GCC。 您可以下载完整的TDM-GCC安装程序,并确保在安装时启用openmp支持。 包也可以,例如gcc-5.1.0-tdm64-1-core.zip ,将gcc-5.1.0-tdm64-1-openmp.zip解压缩到同一文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.