PDA

View Full Version : makefile for the c file on RH 7.2



jasc
01-25-2002, 07:38 AM
Hi, I am newbie to linux, now I am working on an opengl application on redhat linux 7.2, I have the source file my.c. Now I write the makefile like this, is it correct?


CXX = CC
CC = cc
CPPFLAGS = -c -g -I/usr/include -I/usr/include/GL -I/usr/X11R6/include
LFLAGS = -L/usr/lib -L/usr/X11R6/lib -L/lib -lglut -lGLU -lGL -lXmu -lXext -lX11 -lm

TARGET = my
OBJ = my.o

all : $(TARGET)

$(TARGET) : $(OBJ)
$(CC) $(OBJ) $(LFLAGS) -o $(TARGET)

clean:
rm -f $(TARGET) *.o

when I type the make in prompt, it returns error message like this:
....
...
/usr/include/GL/glext.h :2079: parse error before 'pname'
....
...

can anyone help me?

thanks

Tolga Dalman
01-25-2002, 08:29 AM
i haven't used makefiles very much myself, but i think you need a new line after "all:"
and then a tab. also, you should try to generalize your paths, for example TOP=. and INCLUDE= $(TOP)/include, SRC=$(TOP)/src etc. this makes you more flexible. anyway, i don't understand your error message. probably an error in glext.h?

01-25-2002, 11:39 PM
The makefile could perhaps been little easier but the only error I could see was
CXX=CC
CC is set to cc this is the C compiler. CXX is indicating C++ and if you want to specify a C++ compiler should it be something like c++ and not cc.
Anyway, you do not use CXX so your makefile builds the program just as good as any other makefile. The problem is in your code, probably do you forget to include some header.

jide
01-27-2002, 04:42 AM
if your program is only C, no need to cxx.
otherwise, you'll need it, but cc is for c and not C++.
i don't remember correctly, but it may be CXX = C++ i think.

Are you using opengl extensions ? if yes, you'll need to include glx.h too.

i don't see other things, but all: ....
is for when you have more than one source file.

JD