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.
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:
If there are other versions of gcc such as gcc72, you can erase them by:
After that, you will compile the code successfully.