Cre*_*ter 6 opengl glew makefile glfw glm-math
基本上我试图弄清楚为什么编译器抱怨缺少 glew-library:
fatal error: 'GL/glew.h' file not found
Run Code Online (Sandbox Code Playgroud)
我的设置:
酿造清单:
glew
glfw
glm
Run Code Online (Sandbox Code Playgroud)
在 /usr/local/include 目录中:
GL -> ../Cellar/glew/2.0.0/include/GL
GLFW -> ../Cellar/glfw/3.2.1/include/GLFW
glm -> ../Cellar/glm/0.9.8.3/include/glm
Run Code Online (Sandbox Code Playgroud)
和生成文件:
# OBJS specifies which files to compile as part of the project
OBJS = *.cpp
# CC specifies which compiler we're using
CC = g++
# INCLUDE_PATHS specifies the additional include paths we'll need
INCLUDE_PATHS = -I/usr/local/include -I/opt/X11/include
# LIBRARY_PATHS specifies the additional library paths we'll need
LIBRARY_PATHS = -L/usr/local/lib -I/opt/X11/lib
# COMPILER_FLAGS specifies the additional compilation options we're using
# -w suppresses all warnings
COMPILER_FLAGS = -w
# LINKER_FLAGS specifies the libraries we're linking against
# Cocoa, IOKit, and CoreVideo are needed for static GLFW3.
LINKER_FLAGS = -framework OpenGL -lglfw3 -lglew
# OBJ_NAME specifies the name of our exectuable
OBJ_NAME = main
#This is the target that compiles our executable
all : $(OBJS)
$(CC) $(OBJS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(COMPILER_FLAGS) $(LINKER_FLAGS) -o $(OBJ_NAME)
Run Code Online (Sandbox Code Playgroud)
当我在同一目录中有一个名为 File.cpp 的文件时,我运行:
make File
Run Code Online (Sandbox Code Playgroud)
我得到:
fatal error: 'GL/glew.h' file not found
Run Code Online (Sandbox Code Playgroud)
谁能解释为什么上述设置是错误/损坏的?
PS:os,埃尔卡皮坦
您应该确保您的目录结构正确。
例如,您描述了包含的目录结构,如下所示:
Run Code Online (Sandbox Code Playgroud)GL -> ../Cellar/glew/2.0.0/include/GL GLFW -> ../Cellar/glfw/3.2.1/include/GLFW glm -> ../Cellar/glm/0.9.8.3/include/glm
这有点像库的默认目录结构,因为它们从您下载的存档中解压时存在,因此我将引用我的目录结构作为参考:
现在看看你的错误:
Run Code Online (Sandbox Code Playgroud)fatal error: 'GL/glew.h' file not found
除非 1.13.0 和 2.0.0 之间的目录结构发生重大更改,否则很明显您会收到此错误,因为“Include”目录的级别低于您的#include语句尝试访问的级别。
如果您替换#include<GL/glew.h>为#include<glew.h>,您的问题应该得到解决。
或者,不要使用 3 个 include 语句,而是重新组织库并将所有标头放在一个位置,然后通过对主 Include 目录的单个引用来引用它们。