Question

I have been given supposedly working code that I just need to modify, however I can't actually compile the program with the supplied makefile given below.

INCLUDE_PATH = -I/usr/X11/include -I$(BLDR_FREEGLUT_INCLUDE_PATH)
LIBRARY_PATH = -L/usr/X11/lib -L$(BLDR_FREEGLUT_LIB_PATH)
CCFLAGS = -std=c99 
LDFLAGS = -lGL -lGLU -lglut -lX11 -lpthread

GCC = gcc
APP = nbody

all: $(APP)
    @echo Make done

clean:
    @rm -f *.o $(APP)

nbody: nbody.c
    $(GCC) nbody.c -o nbody $(INCLUDE_PATH) $(CCFLAGS) $(LIBRARY_PATH) $(LDFLAGS)

The first output line of the make command gives below.

gcc nbody.c -o nbody -I/usr/X11/include -I -std=c99  -L/usr/X11/lib -L -lGL -lGLU -lglut -lX11 -lpthread

However below that are errors saying that certain things are only "allowed in C99 mode", which I don't understand since the flag for c99 seems to be specified correctly. To troubleshoot this I have tried changing the location of the $(CCFLAGS) value without any success.

How can I modify this makefile so the program complies?

Was it helpful?

Solution

-I -std=c99 says compiler to add directory named -std=c99 to include search paths. This is not what you wanted. Judging by presented fragment, $(BLDR_FREEGLUT_INCLUDE_PATH) is empty - while it shouldn't be. Fix that variable's value and things will go well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top