Makefile checking

I have this makefile code:

MAIN = Block
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++
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

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

Where is this GLTools.h file ?
If in …/Src/GLTools/include/ it should be visible.

Yes…it’s in the correct folder.:frowning:

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 ?

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:

I think I will reuse the makefile which came from the Superbible 5. Thanks for your help.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.