MacOS安装openMP报错【已解决】

error: Target "WLBG" links to: OpenMP::OpenMP_CXX but the target was not found. Possible reasons include: * There is a typo in the target name. * A find_package call is missing for an IMPORTED target. * An ALIAS target is missing.

最开始是报这个错,我以为是cmakeLists出错了,target_link_libraries里面加了OpenMP::OpenMP_CXX。但是我照着gpt给出的解决方案和网上给的方法一通改,在cmakeLists里面加针对macos的一些指令,都不行。

后面我搜macos怎么安装openMP,运行了 brew install gcc,里面自动安装了libomp

但是又报错

fatal error: 'omp.h' file not found

我以为是openmp还是没装对,又搜各种装openmp的指令,以及设置path啥的,但是不是已经装过了就是装不上。我再一看帖子已经是2017、2018年的了,现在已经没有gcc --without-multilib这种选项了,现在openmp是被包含在libomp里的,而libomp又回被brew在安装gcc的时候装上。

我还尝试了修改编译时的参数,加上-fopenmp和路径。但是我是用的qt,尝试在qt里面加上,路径是brew ls gcc找到的。不行,还是报一样的错。

于是搜索fatal error: 'omp.h' file not found,搜到一个帖子https://stackoverflow.com/questions/72706342/openmp-mac-m1-gcc-and-libomp-not-working

照做之后暂时能跑了。。。🙏

虽然很不优雅但是先这样吧。。。

ps. Cmakelists里面的openmp相关是被注视掉了的

相关推荐
Hello.Reader6 小时前
Git 安装全攻略Linux、macOS、Windows 与源码编译
linux·git·macos
Hope Fancy6 小时前
macOS 连接 Docker 运行 postgres,使用navicat添加并关联数据库
macos·docker·postgresql
John Song6 小时前
macOS 上使用 Homebrew 安装redis-cli
数据库·redis·macos
yanjiee6 小时前
编译一个Mac M系列可以用的yuview
macos
数据知道6 小时前
Mac电脑上本地安装 redis并配置开启自启完整流程
数据库·redis·macos
电手12 小时前
Win10停更,Win11不好用?现在Mac电脑比Win11电脑更便宜
windows·macos·电脑·mac
LAOning111 天前
xcode 各版本真机调试包下载
ide·macos·xcode
安和昂1 天前
【iOS】ARC 与 Autorelease
macos·ios·cocoa
数据知道1 天前
Mac电脑上本地安装 MySQL并配置开启自启完整流程
mysql·macos
Cynthia-石头1 天前
Mac 双系统
macos