无法在 C++ 项目中使用 openmp
Can't use openmp in c++ project
我已经将openmp包含到我的项目中。在编译器标志中有-fopenmp
g++ -std=c++0x -O3 -Wall -c -fmessage-length=0 -march=core2 -fopenmp - fast-math -fPIC
#pragma omp parallel for
for (int i = 0; i < rows; i++) {
MatrixXd frame = frames.row(i);
output.row(i) = dem(frame);
}
return output;
当我编译时,我有这样的输出:
hello.cpp:(.text+0x2d88): undefined reference to `omp_get_num_threads'
hello.cpp:(.text+0x2d8f): undefined reference to `omp_get_thread_num'
./hello.o: In function `demodulateMatrix':
hello.cpp:(.text+0x315f): undefined reference to `GOMP_parallel_start'
hello.cpp:(.text+0x316c): undefined reference to `GOMP_parallel_end'
我已经尝试添加-fopenmp标志到链接器,我有这个输出与它
g++: error: unrecognized command line option ‘-fopenmp,’
make: *** [libhello.so] Error 1
您还需要将-fopenmp
传递给链接器。看起来您试图这样做,但是您有一个语法错误,导致链接器看到-fopenmp,
(末尾有一个散乱的逗号)。检查makefile.
(您似乎将hello.cpp
传递给链接器而不是hello.o
,因此您的代码编译两次。)
相关文章:
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 无法在 CLion 中构建 C++ 项目
- 运行同一解决方案的另一个项目的项目
- CMake-按正确顺序将项目与C运行时对象文件链接
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 欧拉项目#8答案是大以获得有效答案
- 从链接列表c++中删除一个项目
- OpenMP阵列性能较差
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 既然存在危险,为什么项目要使用-I include开关
- cmake在我的项目中所需的所有静态库都不成功
- QT通过C++添加映射QML项目
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 在linux上调试巨大的C++项目
- 在其他文件中创建类时在 c++ 项目中不起作用
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- 如何将 OpenMP 和 MPI 导入到大型 CLion CMake 项目中?
- 初学者的OpenMP项目的想法
- 在我的c++项目中禁用OpenMP pragma语句
- 无法在 C++ 项目中使用 openmp