PDA

View Full Version : Makefile checking



charisma
03-01-2011, 04:45 PM
I have this makefile code:



MAIN = Block
SRCPATH = ./
SHAREDPATH = ../Src/GLTools/src/
SHAREDINCPATH = ../Src/GLTools/include/
LIBDIRS = -L/usr/X11R6/lib -L/usr/X11R6/lib64 -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 = -lX11 -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 $(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


But I have the following error.


$ make
g++ -c -o Block.o Block.cpp
Block.cpp:6: fatal error: GLTools.h: No such file or directory
compilation terminated.
make: *** [Block.o] Error 1

ZbuffeR
03-01-2011, 05:25 PM
Where is this GLTools.h file ?
If in ../Src/GLTools/include/ it should be visible.

charisma
03-01-2011, 10:42 PM
Yes...it's in the correct folder.:(

ZbuffeR
03-02-2011, 11:32 AM
and filename and case is exactly correct ?
if you add an include to a <a.h> and create it on that dir, do you have an error message for it too ?

_arts_
03-02-2011, 12:22 PM
Always use CXXFLAGS for C++ instead of CFLAGS (which is for C). Same, doesn't use CC for compiler but CXX.
Because from what I could see, the compilation doesn't take into account your include directory.

You can have a look here, for better writing makefiles: http://www.gnu.org/software/make/manual/make.html#Name-Index

charisma
03-03-2011, 08:07 PM
I think I will reuse the makefile which came from the Superbible 5. Thanks for your help.