我有Windows 8 64位操作系统。
为了实现OpenMP功能,我想尝试使用以下C代码:
hello.c程序
#include <stdio.h>
#include <stdlib.h>
#include<omp.h>
int main()
{
#pragma omp parallel
printf("Hello world!\n");
return 0;
}当我尝试使用:gcc -fopenmp hello.c从命令提示符运行程序时
我得到了以下错误:
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot fin
d -lpthread
collect2.exe: error: ld returned 1 exit status我有C:\MinGW和gcc 4.8.1在我的路上。
我错过了什么?
发布于 2014-04-12 15:33:46
谢谢osgx,
因为我是新手,我搞不懂这些pthreads是什么意思。但毕竟我找到了解决问题的办法。我在我的机器上安装了gcc 4.8.2 64 bit,来自http://www.equation.com/servlet/equation.cmd?fa=fortran。它改变了环境变量(在路径中)本身。安装完成后,我重新启动计算机,然后键入:
gcc -fopenmp hello.c对于命令行中的上述代码,代码工作正常。
发布于 2017-02-20 15:31:58
另一个诀窍是使用gcc码头集装箱。
步骤:
docker pull gccdocker run -it -v /hostfolder:/folderincontainer gcc /bin/bash安装C脚本位于gcc容器中的主机文件夹很简单。不需要担心操作系统的细节。
https://stackoverflow.com/questions/22897169
复制相似问题