1

I have been using gcc version 5.3.0. It says that it comes with openmp support. But every time when I compile a program using either gcc [by terminal] or via xCode 7, I get same error, "file omp.h not found". I have searched too much on this issue and tried almost everything I found.

  • First I tried to locate omp.h on my mac. I found some files; then in header file, I used that specific location of omp.h but no help [it gave me linker error].
  • I installed gcc version 6.0 (pre-release) but no help. I tried changing C_INCLUDE_PATH [which is now, and previously set to none] but that didn't helped me as well.
  • I reinstalled clang-omp but no help.
  • I am using llvm compiler version 7.0. Although i have installed clang-omp, there is no omp.h in my /usr/include/*
smci
  • 32,567
  • 20
  • 113
  • 146
abhinav dwivedi
  • 188
  • 1
  • 7
  • The clang-omp header is installed in /use/local... by Homebrew. Use "brew ls clang-omp" or "find /use/local -name omp.h" to learn its exact location. – Jeff Hammond Jan 31 '16 at 23:53

3 Answers3

2

I changed the compiler and now I am able to run it. [It was issue of clang, which I couldn't solve]. I am a student and Intel is giving Intel Parallel Studio 1 year licence for free to students. So I downloaded, and installed it. In xCode, under build settings, I set my compiler to 'Intel C/C++ compiler' and in parallalization, I turned it to 'yes'. That was it. Then it compiled successfully. But, note that you won't be using header file 'omp.h' anymore. By the way, I am still looking for answers, just to know what I was doing wrong.

abhinav dwivedi
  • 188
  • 1
  • 7
  • What do you mean the header won't be used anymore? You need the header to declare OpenMP runtime library symbols, which is required if you use C99 or later. – Jeff Hammond Jan 31 '16 at 23:51
  • I don't know why, but it still shows openmp.h not found. But my code is able to run now, without header file and output is also true. [yeah i know thats strange, but thats happening :/ ] – abhinav dwivedi Feb 16 '16 at 09:26
  • The OpenMP header is `omp.h`. OpenMP compilers will not provide `openmp.h`. – Jeff Hammond Mar 22 '16 at 13:27
  • I had the same problem a while ago, my solution might help you: https://stackoverflow.com/a/35417448/4603100 – Alejandro Daniel Noel Sep 20 '17 at 02:34
1

You can install 'clang-omp' or 'gcc' (corresponds to GCC 5.3 right now) packages via Homebrew, both of which support OpenMP.

The built in GCC is based upon GCC 4.2.1 abs uses LLVM back end via Dragonegg, which is why it doesn't support OpenMP.

As noted already, Intel compilers support OpenMP on Mac.

I don't use Xcode editor so I don't know how to use any of these from there, but all will work from terminal just as they do on Linux.

Jeff Hammond
  • 5,374
  • 3
  • 28
  • 45
0

the compiler on the mac is clang (based on llvm 3.5) which does not support openmp. you can try install llvm/clang/openmp from source or using prebuild binaries, but I must admit it does not work as advertised for meedit unless you use the -fopenmp=libomp flag.

Community
  • 1
  • 1
rndblnch
  • 183
  • 1
  • 10
  • The Homebrew install of clang-omp works for me. I've not tried to build from source for many years. The Homebrew recipe might reveal any patches required to build from source. – Jeff Hammond Jan 31 '16 at 23:50
  • problem solved with both source and binary install, until 3.8, `-fopenmp` flag does not work, but `-fopenmp=libomp` does. – rndblnch Feb 02 '16 at 08:22