问题描述
我正在尝试在Amazon AWS t2.micro实例上编译测试openmp程序.好像有麻烦了.尝试编译此 OpenMP hello世界程序时,编译器尽管使用gcc hello_world.c -fopenmp
仍找不到omp.h.
I'm trying to compile a test openmp program on an Amazon AWS t2.micro instance. It seems to have trouble. Upon trying to compile this OpenMP hello world program, the compiler fails to find omp.h despite using gcc hello_world.c -fopenmp
.
之后,我尝试运行locate omp.h
,并在/usr/lib/gcc/x86_64-amazon-linux/4.8.5/include
中找到了它.接下来,我尝试通过在该目录中包含gcc -I
进行编译.然后,编译器仍然需要libgomp.spec
,已在堆栈溢出问题.
After that, I tried running locate omp.h
and found it in /usr/lib/gcc/x86_64-amazon-linux/4.8.5/include
. I next attempted to compile by including that directory with gcc -I
. Then, the compiler still needed libgomp.spec
, which has been encountered and solved in this stack overflow question.
通过在其中创建一些符号链接来获得最高评价的答案对我没有任何帮助,即使libgomp.spec
在我的/usr/lib64
目录中,它仍然显示error: libgomp.spec: No such file or directory
.
Following the most upvoted answer on there by creating some symbolic links did nothing for me and still says error: libgomp.spec: No such file or directory
, even though libgomp.spec
is in my /usr/lib64
directory.
那么,我该怎么做才能解决此问题,为什么-fopenmp
无法在Amazon Linux上正常工作?如果有帮助,可以在CfnCluster创建的实例上完成此操作.
So, what can I do to fix this, and why won't -fopenmp
work on amazon linux like expected? This is done on an instance which was created by CfnCluster, if that helps.
推荐答案
像往常一样,头文件(例如omp.h)与gcc编译器的相关版本一起提供.当编译器找不到头文件时,我猜您正在使用其他版本的编译器(本例中为4.8.5除外).
As usual, header files such as omp.h come with relevant version of gcc compiler. When the compiler can't find the header file, I guess you are using the different version compiler (other than 4.8.5 in this case).
您可以通过键入以下内容找到所有gcc版本:
You can find all gcc versions by typing:
sudo yum list installed | grep gcc
如果还有其他gcc版本,例如gcc72,则可以通过以下方式将其删除:
If there are other versions of gcc such as gcc72, you can erase them by:
sudo yum erase gcc72
之后,您将成功编译代码.
After that, you will compile the code successfully.
这篇关于-fopenmp在亚马逊Linux上不包含omp.h吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!