如何使用 openmp 编译 c++?(在 Windows 10 中使用 G++)
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 %dn", 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提取到同一文件夹中。
相关文章:
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 在Linux for Windows上编译C++代码时出错
- 在Windows上用C++裁剪HBITMAP
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到
- 如何加载(或映射)文件部分的最大大小,但适合在Windows上的RAM
- std::threads可以从Windows DLL中的全局变量创建/销毁吗?
- 当我编译webrtc服务器时,Windows上只支持clang-cl
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- Windows/Cygwin - 不能使用 pybind11 - 犯错误
- Windows 10-使用gtkmm-3.0库和g++[包括再现]的分段故障
- 在Windows中以.exe的形式运行c++
- 为什么包含windows.h会产生语法错误,从而阻止类的实例化?(C2146,C2065)
- 无法在windows控制台中为C++程序提供必要的输入
- 在Windows中查找扬声器输出的当前音量级别
- Windows.h与GLFW.h的接口
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 在Linux和C++中的Windows上,散列字符串值会产生不同的输出
- Active Directory:从网络服务帐户下运行的Windows服务调用ADsOpenObject时失败
- c++17文件系统::recursive_directory迭代器()在mac上没有给出这样的目录,但在windows上
- 无法使用Qt Creator在Windows中构建yaml-cpp