- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 macOS 上尝试从 C++ 源代码编译 ASIFT 算法时,我遇到了 OpenMP 库的问题。
编译器为 Apple Clang,macOS 版本为 11.3。
首先编译器告诉我找不到“omp.h”。我引用this question并安装 libomp
通过 HomeBrew。正确安装后,我在源文件中更改以下代码:
#include "omp.h"
到:
#include "/usr/local/opt/libomp/include/omp.h"
这解决了之前的“omp.h not found”错误。
make
后仍然不能正常编译项目源命令。 Clang 抛出链接器错误。终端输出是:
Undefined symbols for architecture x86_64:
"_omp_get_num_procs", referenced from:
compute_asift_matches(int, int, int, int, int, int, int, std::__1::vector<std::__1::vector<std::__1::vector<keypoint, std::__1::allocator<keypoint> >, std::__1::allocator<std::__1::vector<keypoint, std::__1::allocator<keypoint> > > >, std::__1::allocator<std::__1::vector<std::__1::vector<keypoint, std::__1::allocator<keypoint> >, std::__1::allocator<std::__1::vector<keypoint, std::__1::allocator<keypoint> > > > > >&, std::__1::vector<std::__1::vector<std::__1::vector<keypoint, std::__1::allocator<keypoint> >, std::__1::allocator<std::__1::vector<keypoint, std::__1::allocator<keypoint> > > >, std::__1::allocator<std::__1::vector<std::__1::vector<keypoint, std::__1::allocator<keypoint> >, std::__1::allocator<std::__1::vector<keypoint, std::__1::allocator<keypoint> > > > > >&, std::__1::vector<std::__1::pair<keypoint, keypoint>, std::__1::allocator<std::__1::pair<keypoint, keypoint> > >&, siftPar&) in compute_asift_matches.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [demo_ASIFT] Error 1
我还在 Xcode 中编写了一个更简单的代码用于测试:
#include "/usr/local/opt/libomp/include/omp.h"
#include <iostream>
int main()
{
int num = omp_get_num_procs();
std::cout<<num<<std::endl;
}
代码无法正确编译。
omp_get_num_procs()
的实现声明于
omp.h
.
omp_get_num_procs()
的声明在
omp.h
(第 69 行):
extern int __KAI_KMPC_CONVENTION omp_get_num_procs (void);
我不确定这是编译器参数问题还是未正确安装 OpenMP。我已经确认
libomp.a
和
libomp.dylib
正确放置在
/usr/local/opt/libomp/lib
目录。
最佳答案
也许,您应该将 libomp.a 链接到一个项目。 Here示例如何将静态库链接到 Xcode C++ 项目。
关于c++ - 在 macOS 中使用 omp.h 的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67075832/
好的,我希望以前没有问过这个问题,因为在搜索中很难找到。 我查看了 F95 手册,但仍然觉得这很模糊: For the simple case of: DO i=0,99 END DO 我正
这两者有什么区别? [一] #pragma omp parallel { #pragma omp for for(int i = 1; i < 100; ++i) {
这两者有什么区别? [一] #pragma omp parallel { #pragma omp for for(int i = 1; i < 100; ++i) {
我有这段代码: #include #include int main(){ int i,j = 0 ; int tid; # pragma omp parallel pri
刚开始接触OPENMP,想用它来求解波动方程,串口代码在这里: #include #include #include #include #define GRID_SZ 3000 #define
我对 omp single 感到困惑和 omp task指令。我已经阅读了几个使用它们的例子。以下示例显示如何使用任务构造来处理链表的元素。 1 #pragma omp parallel 2 {
我试图了解 omp ordered 和 omp critical 之间的区别。他们都没有相同的语义吗?每个线程中编写的代码都被串行执行,当一个线程处于有序/关键 block 中时,其他线程等待。我看不
是否可以在 omp 并行 block 之外使用 omp pragma,如 critical、single、master 或 barrier?我有一个函数可以从 OMP 并行 block 调用,也可以不
我想测试 #pragma omp parallel for 和 #pragma omp simd 一个简单的矩阵加法程序。当我分别使用它们时,我没有收到任何错误,而且看起来还不错。但是,我想测试使用它
考虑: void saxpy_worksharing(float* x, float* y, float a, int N) { #pragma omp parallel for
我试图了解 #pragma omp critical 之间的确切区别和 #pragma omp single在 OpenMP 中: Microsoft 对这些的定义是: Single:让您指定应在其上
在带有 openMP 的 C++ 中,两者之间有什么区别吗 #pragma omp parallel for for(int i=0; i
我正在处理一些事情,试图让孤立工作发挥作用,并通过减少 #pragma omp parallel 的调用来减少开销。我正在尝试的是这样的: #pragma omp parallel default(n
在我学习 OpenMP 的过程中,我遇到了一个示例,其中的主要内容如下所示: int main(){ #pragma omp parallel #pragma omp sing
我是 OpenMP 的新手,我一直在尝试运行一个使用 OpenMP 添加两个数组的程序。在 OpenMP 教程中,我了解到,在 for 循环上使用 OpenMP 时,我们需要使用 #pragma om
我正在阅读 Peter S. Pacheco 的《并行编程简介》一书。在第 5.6.2 节中,它对减少 fork/join 开销进行了有趣的讨论。 考虑奇偶转置排序算法: for(phase=0; p
之间有什么区别: #pragma omp for {for_loop} 和 #pragma omp parallel for {for_loop} 最佳答案 #pragma omp par
在 OpenMP 中 #pragma omp master 中的任何代码指令由单个线程(主线程)执行,在区域末尾没有隐含的屏障。 (见 section on MASTER directive in t
如果我明白 aligned omp simd的条款构造,它指的是整个数组的对齐方式。 它如何用于多维数组?认为 ni = 131; nj = 137; nk = 127 !allocates arr
我有一个问题:我必须使用 OMP 并行化这段代码。 存在数据依赖问题,不知道如何解决。有什么建议么? for (n = 2; n < N+1; n++) { dz = *(dynamic_d +
我是一名优秀的程序员,十分优秀!