【问题标题】:How can i compile c++ with openmp? (using g++ in windows 10)如何用openmp编译c++? (在 Windows 10 中使用 g++)
【发布时间】:2018-09-13 14:55:07
【问题描述】:

我是 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。 我怎样才能解决这个问题? 谢谢

【问题讨论】:

标签: c++ compilation g++ openmp


【解决方案1】:

对于 MinGW32,This 会有所帮助。

或者您可以使用 TDM-GCC。您可以下载完整的 TDM-GCC 安装程序,并确保在安装时启用 openmp 支持。软件包也可以,例如 gcc-5.1.0-tdm64-1-core.zipgcc-5.1.0-tdm64-1-openmp.zip 提取到相同文件夹。

【讨论】:

    猜你喜欢
    • 2012-08-13
    • 2020-03-15
    • 1970-01-01
    • 2011-01-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多