Makefile for the c file on RH 7.2

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

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?

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.

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

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