jyu429
jyu429

Reputation: 303

OpenMP with g++ MacOS on Sierra

I have a makefile with the following that I'm trying to make on macOS Sierra:

CPP = g++
CPPFLAGS = -m64 -fopenmp -O3

and I keep getting the error clang: error: unsupported option '-fopenmp'.

I did

brew install libomp
brew install llvm
brew install gcc

These all were successful but I still get the same error. Would appreciate any suggestions!

Upvotes: 1

Views: 278

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207345

There are a number of options...


As you have installed llvm with homebrew, you can compile C++ code using OpenMP with:

/usr/local/Cellar/llvm/9.0.0/bin/clang++ -fopenmp main.cpp -o main

As you have installed GCC with homebrew, you can compile C++ code using OpenMP with:

/usr/local/bin/g++-9 -fopenmp main.cpp -o main

As you have installed libomp, you can use that with the Apple-supplied clang++ (note it is not in /usr/local because it is supplied by Apple) to compile C++ with OpenMP with:

/usr/bin/clang++ -I/usr/local/include -Xpreprocessor -fopenmp -L/usr/local/lib -lomp main.cpp -o main

Upvotes: 2

Related Questions