I decided to split a program into pieces since it has become large enough. So I split it up into a few c-files and made the appropriate h-files. Then I created a makefile. Since it’s my first time doing this, I stumbled across several difficulties before getting it to work satisfactory. So, I got it to work under linux in school. However, as I attempt to run a modified version of the makefile under minGW at home, it returns a number of errors. I did a test program which consists of one c-file and its h-file (main.c and main.h) just to simplify the debugging somewhat. Here’s the errors I get under minGW:
$ make gcc -g -Wall -Ic:/Program/mingw/include/ -pipe -fpic -DSHM -Lc:/Program/mingw/lib -lglut32 -lGLU32 -lOpenGL32 -lgdi32 -luser32 -lm main.o -o labb3_4 main.o(.text+0x7cc): In function `solidEllipsoid': c:/mina dokument/program/c/cg/test/main.c:116: undefined reference to `glBegin@4' main.o(.text+0x806):c:/mina dokument/program/c/cg/test/main.c:121: undefined reference to `glNormal3f@12' main.o(.text+0x81d):c:/mina dokument/program/c/cg/test/main.c:123: undefined reference to `glTexCoord2f@8' main.o(.text+0x830):c:/mina dokument/program/c/cg/test/main.c:125: undefined reference to `glTexCoord2f@8' main.o(.text+0x924):c:/mina dokument/program/c/cg/test/main.c:126: undefined reference to `glVertex3f@12' main.o(.text+0x938):c:/mina dokument/program/c/cg/test/main.c:130: undefined reference to `glNormal3f@12' main.o(.text+0x94f):c:/mina dokument/program/c/cg/test/main.c:132: undefined reference to `glTexCoord2f@8' main.o(.text+0x962):c:/mina dokument/program/c/cg/test/main.c:134: undefined reference to `glTexCoord2f@8' etc...
it seems like the compiler doesn’t recognize any of the opengl functions.
If I compile the same file without make and without the header file, I get no complaints and the compilation goes perfectly. The makefile looks like this:
#compiler CC = gcc #compiler flags CFLAGS = -c -g -Wall CFLAGS += -DGLUT_DISABLE_ATEXIT_HACK -D_STDCALL_SUPPORTED #linker LD = gcc #linker libraries #LDLIBS = -lglut -lGLU -lGL -luser GLUTLIB=c:/Program/mingw/lib GLUTINC=c:/Program/mingw/include/ LDFLAGS = -g -Wall -I$(GLUTINC) -pipe -fpic -DSHM LDFLAGS += -L$(GLUTLIB) LDFLAGS += -lglut32 -lGLU32 -lOpenGL32 -lgdi32 -luser32 LDFLAGS += -lm labb3_4: main.o $(LD) $(LDFLAGS) $? -o $@ main.o: main.c main.h $(CC) $(CFLAGS) $< -o $@ clean: rm -rf main.o main
This problem is driving me nuts! Someone knows a fix for this?