未定义对`omp_get_wtime'的引用 [英] undefined reference to `omp_get_wtime'

查看:280
本文介绍了未定义对`omp_get_wtime'的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学习c ++,OpenMP.我尝试使用omp_get_wtime编译程序,但它不起作用,但是当我删除它时,它可以工作.我必须添加一些东西,但是在什么地方.在openmptryflags还是Cmakelists中?

i learn c++, OpenMP. I have tried compile my program with omp_get_wtime and it doesn't work, but when i deleted this, it works. i must add something, but what and where. In openmptryflags or Cmakelists?


snap/clion/61/bin/cmake/linux/bin/cmake --build /home/bapah/CLionProjects/omp1/cmake-build-debug --target omp1 -- -j 6
[ 50%] Linking CXX executable omp1
CMakeFiles/omp1.dir/main.cpp.o: In function `main':
/home/bapah/CLionProjects/omp1/main.cpp:36: undefined reference to `omp_get_wtime'
collect2: error: ld returned 1 exit status
CMakeFiles/omp1.dir/build.make:83: recipe for target 'omp1' failed
make[3]: *** [omp1] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/omp1.dir/all' failed
make[2]: *** [CMakeFiles/omp1.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/omp1.dir/rule' failed
make[1]: *** [CMakeFiles/omp1.dir/rule] Error 2
Makefile:118: recipe for target 'omp1' failed
make: *** [omp1] Error 2

推荐答案

解决方案:添加到CMakeList.txt

Solution : add to CMakeList.txt

SET_TARGET_PROPERTIES(omp1 PROPERTIES COMPILE_FLAGS "-fopenmp"
    LINK_FLAGS "-fopenmp")

P.s.omp1-为您的项目命名.

P.s. omp1 - name your project.

P.p.s.您也可以编写 target_link_libraries(omp1 -fopenmp)

P.p.s. also you can write target_link_libraries(omp1 -fopenmp)

这篇关于未定义对`omp_get_wtime'的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆