MacOS M1 -> 致命错误:找不到“GLFW/glfw3.h”文件

Ped*_*rsi 9 c++ glfw visual-studio-code apple-m1

我有一个项目(此处)可以在 Linux 和 intel MacOS 上运行,但在我的 Mac m1 上却不能。每当我尝试编译它时,我都会收到以下错误(操作:我正在使用 vscode m1 本机):

pedrohaccorsi@MacBook-Air-de-Pedro dev % make
g++ -o app src/glad.c src/AudioManager.cpp src/Character.cpp src/SceneManager.cpp src/Source.cpp src/Sprite.cpp src/stb_image.cpp -g -Iinclude -F/Library/Frameworks -lglfw -ldl -framework SDL2 -I/Library/Frameworks/SDL2.framework/Headers -framework SDL2_mixer -I/Library/Frameworks/SDL2_mixer.framework/Headers


In file included from src/AudioManager.cpp:1:
include/AudioManager.h:1:10: fatal error: 'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
         ^~~~~~~~~~~~
1 error generated.
In file included from src/Character.cpp:1:
In file included from include/Character.h:1:
In file included from include/Sprite.h:6:
include/Shader.h:13:10: fatal error: 'GLFW/glfw3.h' file not found
#include <GLFW/glfw3.h>
         ^~~~~~~~~~~~~~
1 error generated.
In file included from src/SceneManager.cpp:1:
In file included from include/SceneManager.h:3:
include/Shader.h:13:10: fatal error: 'GLFW/glfw3.h' file not found
#include <GLFW/glfw3.h>
         ^~~~~~~~~~~~~~
1 error generated.
src/Source.cpp:10:17: warning: using directive refers to implicitly-defined namespace 'std'
using namespace std;
                ^
In file included from src/Source.cpp:12:
In file included from include/SceneManager.h:3:
include/Shader.h:13:10: fatal error: 'GLFW/glfw3.h' file not found
#include <GLFW/glfw3.h>
         ^~~~~~~~~~~~~~
1 warning and 1 error generated.
In file included from src/Sprite.cpp:1:
In file included from include/Sprite.h:6:
include/Shader.h:13:10: fatal error: 'GLFW/glfw3.h' file not found
#include <GLFW/glfw3.h>
         ^~~~~~~~~~~~~~
1 error generated.
make: *** [app] Error 1
Run Code Online (Sandbox Code Playgroud)

之前我运行了这三个命令,它们成功运行,没有任何错误或警告,所以我认为一切正常。

brew install glfw
brew install sdl2
brew install sdl2_mixer
Run Code Online (Sandbox Code Playgroud)

有人有什么想法吗?

Ped*_*rsi 11

我的问题得到了部分解决。有两个问题,GLFW并且SDL2

GLFW

该修复与该线程中提出的修复相同;简而言之,它包括:

$ nano ~/.zshrc
> export CPATH=/opt/homebrew/include
> export LIBRARY_PATH=/opt/homebrew/lib
Run Code Online (Sandbox Code Playgroud)

这将告诉编译器在 中查找内容opt/homebrew,这是安装包的位置homebrewm1而不是usr/local.

SDL2

.dmg我从以下网站下载了这两个文件

  1. https://www.libsdl.org/download-2.0.php
  2. https://www.libsdl.org/projects/SDL_mixer/

然后我转到下载并.framework从两个下载中复制目录并粘贴到/Library/Frameworks.

这解决了之前的错误,即系统找不到包含的内容,但出现了一个新错误:symbols not found for architecture arm64。我决定放弃尝试,只是从游戏中删除了声音(这是一项大学作业,删除功能没什么大不了的)。