MacOS M1 ->致命错误:找不到“GLFW/glfw3.h"文件 [英] MacOS M1 -> fatal error: 'GLFW/glfw3.h' file not found

查看:160
本文介绍了MacOS M1 ->致命错误:找不到“GLFW/glfw3.h"文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目 (这里)Linux 和 intel MacOS,但在我的 Mac m1 中却没有.每当我尝试编译它时,我都会收到以下错误(操作:我使用的是 vscode m1 native):

I have a project (here) that works both on Linux and intel MacOS, but in my Mac m1 it doesn't. Whenever I try to compile it, I get the following errors (ops.: I'm using vscode m1 native):

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

之前我运行了这三个命令并且它们运行成功,根本没有错误或警告,所以我认为一切正常.

Before hand I ran these three commands and they worked successfully, no errors nor warnings at all, so I assumed it was all working fine.

brew install glfw
brew install sdl2
brew install sdl2_mixer

有人有什么想法吗?

推荐答案

我的问题已部分解决.有两个问题,GLFWSDL2.

My issue was partially solved. There were two problems, GLFWand SDL2.

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

The fix was the same proposed in this thread; in a nutshell it consists in:

$ nano ~/.zshrc
> export CPATH=/opt/homebrew/include
> export LIBRARY_PATH=/opt/homebrew/lib

这将告诉编译器在 opt/homebrew 中寻找东西,这是 homebrew for m1 安装包的地方,而不是usr/local.

This will tell the compiler to look for things in opt/homebrew, which is where homebrew for m1 installs the packages, instead of usr/local.

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

I downloaded the two .dmg files from the websites below

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

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

Then I went to the downloads and copied the .framework directory from both downloads and pasted into /Library/Frameworks.

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

This solved those errors from before, that the system could not find the includes, but a new error showed up: symbols not found for architecture arm64. I decided to quit trying and just removed the sound out of my game (it was a college assignment, no biggie in taking features out).

这篇关于MacOS M1 ->致命错误:找不到“GLFW/glfw3.h"文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆