-fopenmp does not include omp.h on amazon linux?

2019-08-19 12:59发布

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.

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.

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.

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.

1条回答
孤傲高冷的网名
2楼-- · 2019-08-19 13:53

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).

You can find all gcc versions by typing:

sudo yum list installed | grep gcc

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.

查看更多
登录 后发表回答