相关疑难解决方法(0)

在OS X Yosemite上使用gcc编译器编译OpenMP程序

$ gcc 12.c -fopenmp
12.c:9:9: fatal error: 'omp.h' file not found
#include<omp.h>
    ^
1 error generated.
Run Code Online (Sandbox Code Playgroud)

在编译openMP程序时,我得到了上述错误.我正在使用OS X Yosemite.我首先尝试通过在终端中键入gcc来安装本机gcc编译器,后来又下载了Xcode,我得到了同样的错误.然后我下载了gcc:

$ brew install gcc
Run Code Online (Sandbox Code Playgroud)

我仍然得到同样的错误.我确实尝试更改编译器路径,它仍显示:

$ which gcc
/usr/bin/gcc
Run Code Online (Sandbox Code Playgroud)

那么如何用gcc编译程序呢?

c c++ xcode gcc openmp

14
推荐指数
1
解决办法
3万
查看次数

为 macOS-x86_64 构建,但尝试链接为 macOS-arm64 构建的文件

我用c++和OpenCV写了一段代码:

#include <iostream>
#include <time.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>

using namespace std;

int main()
{
    ...
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

然后我尝试在终端上运行我的代码并使用 g++ 进行构建:

g++ $(pkg-config --cflags --libs opencv) -std=c++11  yourFile.cpp -o yourFileProgram
Run Code Online (Sandbox Code Playgroud)

但我收到此错误:

...
ld: warning: ignoring file /opt/homebrew/Cellar/opencv/4.5.1_2/lib/libopencv_core.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file /opt/homebrew/Cellar/opencv/4.5.1_2/lib/libopencv_photo.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
  "cv::Mat::Mat()", referenced from:
      _main in cv_test-ff1014.o
  "cv::Mat::~Mat()", referenced …
Run Code Online (Sandbox Code Playgroud)

c++ macos opencv g++

10
推荐指数
1
解决办法
3万
查看次数

标签 统计

c++ ×2

c ×1

g++ ×1

gcc ×1

macos ×1

opencv ×1

openmp ×1

xcode ×1