【发布时间】:2019-07-22 21:56:06
【问题描述】:
我学习 C++、OpenMP。我试过用 omp_get_wtime 编译我的程序,但它不起作用,但是当我删除它时,它起作用了。我必须添加一些东西,但是什么和在哪里。在 openmptryflags 或 Cmakelists 中?
snap/clion/61/bin/cmake/linux/bin/cmake --build /home/bapah/CLionProjects/omp1/cmake-build-debug --target omp1 -- -j 6 [ 50%] 链接 CXX 可执行文件 omp1 CMakeFiles/omp1.dir/main.cpp.o:在函数“main”中: /home/bapah/CLionProjects/omp1/main.cpp:36:未定义对“omp_get_wtime”的引用 collect2:错误:ld 返回 1 个退出状态 CMakeFiles/omp1.dir/build.make:83:目标“omp1”的配方失败 make[3]: *** [omp1] 错误 1 CMakeFiles/Makefile2:72:目标“CMakeFiles/omp1.dir/all”的配方失败 make[2]: *** [CMakeFiles/omp1.dir/all] 错误 2 CMakeFiles/Makefile2:84:目标“CMakeFiles/omp1.dir/rule”的配方失败 make[1]: *** [CMakeFiles/omp1.dir/rule] 错误 2 Makefile:118: 目标“omp1”的配方失败 制作:*** [omp1] 错误 2【问题讨论】:
-
听起来您可能缺少
-fopenmp。您可以在问题中添加编译器或链接器命令行吗? -
我必须在哪里添加-fopenmp?
-
恐怕我不知道。我使用不同的构建工具。
-
你用什么? ubuntu 有什么更好的。我使用 Clion 和 Cmake
-
如何在工具中添加-fopenmp?