为什么Glew在MacOS Catalina中找不到OpenGL标头?

问题描述

升级到Catalina破坏了我的构建,而三天的搜索未能解决问题。该代码在卡塔利娜(Catalina)之前运行良好。

我遇到的具体错误是

/usr/local/include/GL/glew.h:1217:14: fatal error: 'OpenGL/glu.h' file not found
#    include <OpenGL/glu.h>
             ^~~~~~~~~~~~~~ /usr/local/include/GL/glew.h:1217:14: 
note: did not find header 'glu.h' in
      framework 'OpenGL' (loaded from '/System/Library/Frameworks')

我的毛病是从brew安装的,并且brew信息显示:

$ brew info glew
glew: stable 2.2.0 (bottled),HEAD
OpenGL Extension Wrangler Library
https://glew.sourceforge.io/
Conflicts with:
  root (because root ships its own copy of glew)
/usr/local/Cellar/glew/2.2.0 (38 files,3.4MB) *
  Poured from bottle on 2020-10-27 at 10:52:58
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/glew.rb
License: BSD-3-Clause
==> Dependencies
Build: cmake ✔
==> Options
--HEAD
    Install HEAD version
==> Analytics
install: 6,917 (30 days),12,565 (90 days),50,126 (365 days)
install-on-request: 3,383 (30 days),6,400 (90 days),26,243 (365 days)
build-error: 0 (30 days)

据我所知,关于“ root拥有自己的glew副本”的部分不是这种情况,因为整个系统的find搜索都找不到另一个glew.h。

我的构建标志是(通过CMake设置的)

SET(APP_COMPILE_FLAGS  "-g -Wall -Wno-nullability-completeness")
SET(APP_LINK_FLAGS     "-framework OpenGL -lglfw -lGLEW")

其他可能相关的信息:

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

我正在运行XCode 12.0.1,用于XCode 12的命令工具和MacOS 10.15.7。有见识吗?

解决方法

这显然不是理想的正确答案,但是创建链接

/usr/local/include/OpenGL -> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers

可以解决我的问题。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...