I have a problem with my Makefiles on Gentoo Linux.
Here is my folder hierarchy:
Development
-> GLTools
-> include
-> src
->Triangle
->triangle.cpp
->Makefile
and my 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
My problem is that get the following error:
demonking@Master ~/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
But when I copy my Makefile to the folder Development (a folder up one level) and edit my paths it compiles without any errors.
Why do I get an error when my triangle.cpp and Makefile are in one folder and I try to access GLTools in the parent folder?
The default rule for compiling c++ uses
CXXFLAGSrather thanCFLAGS, and you haven’t set it so it does not includeINCDIRS.Add
and try again.
The way you would have spotted this yourself is by reading the output of make. Notice the first line in the output you exhibit:
No include flags. No
-g. None of the stuff that you took all the trouble to set up.