我的Gentoo Linux上的Makefiles有問題。具有相對路徑的Makefile?
這裏是我的文件夾層次:
Development
-> GLTools
-> include
-> src
->Triangle
->triangle.cpp
->Makefile
和我的Makefile:
MAIN = triangle
SRCPATH = ./
SHAREDPATH = ../GLTools/src/
SHAREDINCPATH = ../GLTools/include/
LIBDIRS = -L/usr/local/lib
INCDIRS = -I/usr/include -I/usr/local/include -I/usr/include/GL \
-I$(SHAREDINCPATH) -I$(SHAREDINCPATH)GL
CC = g++
CFLAGS = $(COMPILERFLAGS) -g $(INCDIRS)
LIBS = -lglut -lGL -lGLU -lm
prog : $(MAIN)
$(MAIN).o : $(SRCPATH)$(MAIN).cpp
glew.o : $(SHAREDPATH)glew.c
GLTools.o : $(SHAREDPATH)GLTools.cpp
GLBatch.o : $(SHAREDPATH)GLBatch.cpp
GLTriangleBatch.o : $(SHAREDPATH)GLTriangleBatch.cpp
GLShaderManager.o : $(SHAREDPATH)GLShaderManager.cpp
math3d.o : $(SHAREDPATH)math3d.cpp
$(MAIN) : $(MAIN).o glew.o
$(CC) $(CFLAGS) -o $(SRCPATH)$(MAIN) $(LIBDIRS) $(SRCPATH)$(MAIN).cpp \
$(SHAREDPATH)glew.c $(SHAREDPATH)GLTools.cpp $(SHAREDPATH)GLBatch.cpp\
$(SHAREDPATH)GLTriangleBatch.cpp $(SHAREDPATH)GLShaderManager.cpp \
$(SHAREDPATH)math3d.cpp $(LIBS)
clean:
rm -f *.o
我的問題是出現以下錯誤:
[email protected] ~/Development/Triangle $ make
g++ -c -o triangle.o triangle.cpp
triangle.cpp:4:50: error: GLTools.h: No such file or directory
triangle.cpp:5:56: error: GLShaderManager.h: No such file or directory
但是,當我複製我的Makefile到文件夾開發(一個文件夾上一級),並編輯我編寫的路徑,沒有任何錯誤。
爲什麼我的triangle.cpp和Makefile在一個文件夾中時出現錯誤,我嘗試訪問父文件夾中的GLTools?
THX很多:d它有助於 – demonking
這究竟是爲什麼? OP實際上特別把CFLAG放在應該正確擴展的命令中(像任何變量) – texasbruce