0
votes

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.

1
GCC comes with its own OpenMP implementation (libgomp) and the path to its omp.h is added automatically when -fopenmp is specified. As far as I see, you want to link against the Intel OpenMP runtime which provides a compatibility layer with libgomp API. You should be able to simply use -fopenmp and #include <omp.h> at compile time and then link against IOMP without the -fopenmp flag (if GCC is also used as linker). - Hristo Iliev

1 Answers

0
votes

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.