0

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). Commented Jul 23, 2015 at 12:34

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Hn.. Thank you. I thought there could be an environment variable or something after the brew install.
Not to forget: directory & file names with spaces. In this case his path needs to start and end with " (quote), otherwise the path gets splitted in multiple arguments.
@Youka: Which space? There is no space in the name quoted in the question. Yes, in theory you're right. In practice, people writing programs generally assume that there are no spaces in pathnames. I used to have a directory External Source Repositories with various SVN, Git and Mercurial clones in it. It didn't last long; none of the autoconfiscated software (code using autoconf and relatives) handled the path name with blanks in it. The directory is now External-Source-Repositories. I'm not talking about shabby third-rate projects having problems; these were mainstream FLOSS projects.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.