omp.h not found, OS X Yosemite not using newest gcc version

13,445

Solution 1

I solved this with installing gcc with homebrew:

brew install gcc --without-multilib

and then building the source code with

CC=gcc-5 CXX=g++-5 cmake ..
CC=gcc-5 CXX=g++-5 make -j7

Solution 2

Once you have installed gcc-4.9 with homebrew, it will automatically be in your path. To use OpenMP, you just need to make sure you are using the newly installed gcc-4.9, and it will be able to find omp.h.

In the case of GraphChi, you will have to go change line 3 of the Makefile to be gcc-4.9. From there, running make should just work. They describe this in their README, but at least the version they describe is out of date https://github.com/GraphChi/graphchi-cpp#problems-compiling-on-mac.

Share:
13,445
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I am trying to build GraphChi on OS X Yosemite but get the following error:

    fatal error: 'omp.h' file not found

    From this question - How to include omp.h in OS X? - I learned that Yosemite uses Clang instead of gcc, which does not include omp.h.

    $ which gcc
    /usr/bin/gcc
    $ gcc -v
    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
    Target: x86_64-apple-darwin14.1.0
    Thread model: posix
    

    Next, I installed gcc via Homebrew

    $ brew info gcc
    gcc: stable 4.9.2 (bottled)
    http://gcc.gnu.org
    /usr/local/Cellar/gcc/4.9.2_1 (1092 files, 177M)
    Built from source with: --without-multilib
    

    and updated $PATH to include the path to the new gcc version

    $ echo $PATH
    /usr/local/Cellar/gcc/4.9.2_1:usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
    

    however, gcc -v and which gcc still point to the old version, and building GraphChi still doesn't work due to the missing omp.h file

    Does anyone know what else I need to do?

    Update

    locate omp.h returned:

    /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/lib/gcc/i686-apple-darwin11/4.2.1/include/omp.h
    /usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9/gcc/x86_64-apple-darwin14.1.0/4.9.2/include/omp.h
    /usr/local/Cellar/gfortran/4.8.2/gfortran/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/include/omp.h
    

    my ~/.profile:

    export PATH=/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9/gcc/x86_64-apple-darwin14.1.0/4.9.2/include:/usr/local/Cellar/gcc/4.9.2_1/bin:usr/local/bin:/opt/local/bin:/opt/local/sbin:$PATH