我正在尝试在Mac的Clion中编译OpenMP项目。
我尝试过
How to set up basic openMP project in CLion
How to set linker flags for OpenMP in CMake's try_compile function
但是它们都不对我有用。 Clion只是说:
-找不到OpenMP_C(缺少:OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-找不到OpenMP_CXX(缺少:OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-找不到OpenMP(丢失:OpenMP_C_FOUND OpenMP_CXX_FOUND)
我还尝试在命令行中使用“ gcc -o main -fopenmp main.c”进行编译,并且工作正常。
代码如下:
#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;
}