0

I need to install OpenMP on my Mac and use it in CLion. I re-installed gcc, confirmed I have it, /usr/bin/local/gcc-7. Do not understand if this comes with OpenMP or if I need to install something extra.

CMakeLists.txt

cmake_minimum_required(VERSION 3.9)
project(lab_3)

set(CMAKE_CXX_STANDARD 11)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")

add_executable(lab_3 main.cpp)

main.cpp

#include <iostream>
#include <omp.h>

int main() {

#pragma omp parallel for

    for (int i=0; i<10; i++) {
        std::cout << "This is thread #" << omp_get_thread_num() << std::endl;
    }

    return 0;
}

Error message:

clang: error: unsupported option '-fopenmp'

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
j wu
  • 1
  • 1
  • https://stackoverflow.com/a/36211162/2850543. You're compiling with clang, not gcc. – Millie Smith Mar 01 '18 at 23:53
  • Can you explain further please? – j wu Mar 01 '18 at 23:57
  • OK, I was able to fix it by going into CLion and changing the default compiler to gcc. Thanks for pointing this out, did not even know what clang was. – j wu Mar 02 '18 at 00:08
  • 1
    Possible duplicate of [clang: error: : errorunsupported option '-fopenmp' on Mac OSX El Capitan building XGBoost](https://stackoverflow.com/questions/36211018/clang-error-errorunsupported-option-fopenmp-on-mac-osx-el-capitan-buildin) – High Performance Mark Mar 02 '18 at 15:08

0 Answers0