3

I am trying to compile an OpenMP prject in Clion on Mac.

I have tried

How to set up basic openMP project in CLion

How to set linker flags for OpenMP in CMake's try_compile function

CMake cannot find OpenMP

But they all don't work for me. Clion just says:

-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)

-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)

-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)

I also tried compile it using "gcc -o main -fopenmp main.c" in the command line and it works fine.

Here is the code:

#include <stdio.h>
#include <omp.h>
int main() {
printf("Hello, World!\n");
#pragma omp parallel
printf("Hello world from thread %d\n",omp_get_thread_num());
return 0;
}
  • 3
    I know it's silly, but I had a very similar error (which I why I found this question), and just solved it by deleting everything in the build directory. I'm using a simple CMake project, but clion should be the same. – mjgalindo Jan 23 '19 at 12:13
  • 1
    @mjgalindo Actually, CLion caches all of this configuration in the build directory. I faced the same issue as above despite having another CLion project running on the same machine with OpenMP. I can confirm that, after deleting *everything* in the build directory, you must `Reload CMake Project` and verify that it retrieves the OpenMP configuration. Then you can build the project as usual. – 영민 카이 앤절 May 28 '21 at 02:45

0 Answers0