My gcc compiles well, but clang fails with the following message:

clang -fopenmp=libomp -o main main.c
main.c:5:10: fatal error: 'omp.h' file not found

I also installed libomp5 package and changed flag to -fopenmp=libomp5 , though it didn't help either:

clang -fopenmp=libomp5 -o main main.c
clang: error: unsupported argument 'libomp5' to option 'fopenmp='
clang: error: unsupported argument 'libomp5' to option 'fopenmp='

these recommendations didn't work.

Would be grateful for hints on installing necessary 16.04 specific packages and passing corresponding flags.

  • What version of Clang are you using? I have the same problem BTW with clang-3.8 and clang-3.9 on Ubuntu 16.10. – Z boson Apr 12 '17 at 13:47
  • 1
    sudo apt install libomp-dev – Z boson Apr 12 '17 at 13:55
  • Finally, I can use OpenMP with Clang on Ubuntu! I have wanted this for a long time!. – Z boson Apr 12 '17 at 13:59

I had the same problem.

sudo apt install libomp-dev

Fixed it with Ubuntu 16.10

#include "omp.h"
#include <stdio.h>

int main(void) {
  #pragma omp parallel
  printf("thread %d\n", omp_get_thread_num());


clang test.c -fopenmp
thread 0
thread 5
thread 2
thread 1
thread 7
thread 3
thread 4
thread 6


clant-3.9 test.c -fopenmp


GCC and Clang use different OpenMP runtime libraries : libgomp and libomp respectivly.

Clang's runtime is the LLVM OpenMP runtime which in turn is based on the Intel OpenMP runtime (which is open source). https://www.openmprtl.org/

On my system GCC installed omp.h at


and libomp-dev insalled omp.h at


These are different header files which include different function definitions. It may be okay to use either header file for e.g. omp_get_wtime() but in general I think it's probably better to use the header file that corresponds to the runtime that is linked to.

  • 1
    Worked on vanilla 16.04 with stock clang in repos. – Bulat M. Apr 14 '17 at 5:43
  • 1
    I justed installed Ubuntu 17.04 which defaults to Clang 4.0. I stilled had to use sudo apt install libomp.dev. – Z boson Apr 21 '17 at 7:05
  • If you accidentally link libgomp from clang 6, your code will be silently serialized. – Andrew Wagner Feb 27 '19 at 11:25
  • clant-3.9 test.c -fopenmp shoud be clang-3.9 test.c -fopenmp? – Henke Nov 24 '20 at 15:32

It seems omp.h file doesn't exist in your system PATH. firstly try to locate omp.h file if you don't know where it is:

find / -name 'omp.h' -type f

And then run this command to compile your code:

clang -o main main.c -I/path/to/omp/folder
  • That does not fix the problem. It still can't find omp.h. – Z boson Apr 12 '17 at 13:48
  • Did you find any omp.h in your system? can you append output of these commands to your question? – Ghasem Pahlavan Apr 13 '17 at 7:48
  • *.h are header files, why would he want to add them into his path? they should be in /usr/include for example. – Ravexina Apr 13 '17 at 11:15
  • 1
    Thanks Ghasem, libomp-dev installation on 16.04 solved. – Bulat M. Apr 14 '17 at 5:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.