本文介绍了如何在新的MacBook Pro(带有Mac OS Catalina)上安装openMP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了Xcode(以及命令行工具),但终端机提示(编译时):

I installed Xcode (and also the command line tools) but terminal says (when I'm compiling):

gcc -o task -fopenmp task.c
clang: error: unsupported option '-fopenmp'

我尝试通过brew安装openmp,但是人们说它在自制软件上不再可用,他们建议尝试

I tried to install openmp via brew but people say that it's not available anymore on homebrew, they suggest to try

brew instal llvm

但是我得到了同样的错误.我也在骨场尝试过

But I get the same error.I tried also in the boneyard

brew install homebrew/boneyard/clang-omp

但是该存储库不再存在.

but the repository doesn't exist anymore.

你能帮我吗?我只需要学习openMP,我认为安装起来并不那么困难...

Could you help me?I just need to learn openMP, I don't think that is so difficult to install...

谢谢!

亲切的问候,

Nico

推荐答案

https://iscinumpy.gitlab.io/post/omp-on-high-sierra/建议执行以下操作:

brew install libomp

要安装OpenMP运行时组件/库.

To install the OpenMP runtime components/libraries.

然后,在编译时:

  • 在编译步骤(-c选项)中使用-Xpreprocessor -fopenmp代替-fopenmp
  • -lomp添加到链接步骤
  • use -Xpreprocessor -fopenmp in place of -fopenmp in the compile step (-c option)
  • add -lomp to the linking step

请注意,以上页面还提到CMake 3.12或更高版本将自动找到在MacOS上添加OpenMP的正确方法:

Note that the above page also mention that CMake 3.12 or later will automatically find the right way of adding OpenMP on MacOS:

cmake_minimum_required(VERSION 3.12)
project(openmptest CXX)

add_executable(sample sample.cpp)

find_package(OpenMP REQUIRED)
target_link_libraries(sample PRIVATE OpenMP::OpenMP_CXX)

注意:我没有测试任何一个,但是听起来比较理智

这篇关于如何在新的MacBook Pro(带有Mac OS Catalina)上安装openMP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 00:55