c++ - How to set up basic openMP project in CLion -


this question has answer here:

i trying run simple openmp program in clion ide. when run error:

cmakefiles\openmp_test_clion.dir/objects.a(main.cpp.obj): in function `main': d:/.../openmp_test_clion/main.cpp:9: undefined reference 'omp_get_thread_num' collect2.exe: error: ld returned 1 exit status 

here code:

#include <stdio.h> #include <omp.h>  int main() {     int id; #pragma omp parallel private(id)     {         id = omp_get_thread_num();         printf("%d: hello world!\n", id);     }     return 0; } 

here cmakelists.txt:

cmake_minimum_required(version 3.6) project(openmp_test_clion)  set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11")  set(source_files main.cpp) add_executable(openmp_test_clion ${source_files})  message(status "checking openmp") find_package(openmp) if(openmp_found)     message("found openmp!)     # add flags openmp     set(cmake_c_flags "${cmake_c_flags} ${openmp_c_flags}")     set(cmake_cxx_flags "${cmake_cxx_flags} ${openmp_cxx_flags}")     set(cmake_shared_linker_flags "${cmake_shared_linker_flags} ${openmp_shared_linker_flags}")     set(cmake_exe_linker_flags "${cmake_exe_linker_flags} ${openmp_exe_linker_flags}") else()     message("missed openmp!") endif() 

here screen of toolchains: enter image description here

i have 0 experience openmp , beginner programmer in c++ please give me bit of explanation how setup project.

so after while figured out. changed cmakelists.txt following:

cmake_minimum_required(version 3.6) project(openmp_test_clion)  # added -fopenmp set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11 -fopenmp")  set(source_files main.cpp) add_executable(openmp_test_clion ${source_files}) 

and needed install openmp via tdm-gcc installer .


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -