Thomas Wang
Thomas Wang

Reputation: 2061

how to include "omp.h" without specifying exact path on OS X

I can build my project by using

#include "/usr/local/Cellar/libiomp/20150401/include/libiomp/omp.h"

and also set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fopenmp")in the CMakeLists.txt

but what should I do to just #include <omp.h>?

When I brew list, I have clang-omp, libivmp, gcc installed. I found that omp.h by using locate omp.h.

And my gcc -v prints:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin14.4.0/5.1.0/lto-wrapper
Target: x86_64-apple-darwin14.4.0
Configured with: ../gcc-5.1.0/configure --enable-languages=c++,fortran
Thread model: posix
gcc version 5.1.0 (GCC)

Thanks in advance.

Upvotes: 0

Views: 1223

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 754820

You should be able to do it with a command line option for the C or C++ compiler:

-I /usr/local/Cellar/libiomp/20150401/include/libiomp

(space between -I and path optional) on the compiler command line. You might well have a variable that identifies /usr/local/Cellar/libiomp/20150401 as the location where the OMP code is installed, because the chances are you also need an option -L /usr/local/Cellar/libiomp/20150401/lib (space optional again) to pick up the libraries when you link, too.

Fixing that in your CMakeLists.txt file is a somewhat separate discussion, but you're likely to be able to find some exemplars that will help there.

Upvotes: 0

Related Questions