Davy Li Davy Li - 11 days ago 8
C++ Question

Error enabling openmp - "ld: library not found for -lgomp" and Clang errors

I'm trying to get openmp to run in my program on Mavericks, however when I try to compile using the flag

I get the following error:

ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The command I am running is:

gcc myProgram.cpp -fopenmp -o myProgram

Also, when I run gcc I get Clang warnings which I find to be very strange. And looking into /usr/bin/gcc it does not appear to link to Clang.

Any suggestions on how to fix my Clang errors and get openmp to compile?


The gcc command in the latest Xcode suite is no longer the GCC frontend to LLVM (based on the very old GCC 4.2.1) but rather a symlink to clang. Clang does not (yet) support OpenMP. You have to install separately another version of GCC, e.g. by following this tutorial or by using any of the available software package management systems like MacPorts and Homebrew.