Unexplained problem

Hello. i made a program on linux for opengl and i made a makefile like this:


############################################
GLIBS = -lglut -lGLU -lGL
XLIBS = -L/usr/X11R6/lib -lXext -lX11

cubemap : cubemap.o tga.o
g++ -Wall -o $@ -mtune=generic cubemap.o tga.o $(GLIBS) $(XLIBS) -lm

cubemap.o : cubemap.c tga.h
g++ -Wall -c cubemap.c

tga.o : tga.c tga.h
g++ -Wall -c tga.c

clean:
/bin/rm -f cubemap.o tga.o cubemap
############################################


My program worked fine. But when i wanted to add (glui) menu, i changed slightly the above makefile into this:


############################################################
#new Makefile

GLIBS = -lglui -lglut -lGLU -lGL
XLIBS = -L/usr/X11R6/lib -lXext -lX11

cubemap : cubemap.o tga.o
g++ -Wall -o $@ -mtune=generic cubemap.o tga.o $(GLIBS) $(XLIBS) -lm

cubemap.o : cubemap.c tga.h
g++ -Wall -c cubemap.c

tga.o : tga.c tga.h
g++ -Wall -c tga.c

clean:
/bin/rm -f cubemap.o tga.o cubemap

##########################################################

Then i had this mistake:

g++ -Wall -c cubemap.c
g++ -Wall -o cubemap -mtune=generic cubemap.o tga.o -lglut -lGLU -lGL -L/usr/X11R6/lib -lXext -lX11 -lm
cubemap.o: In function `main':
cubemap.c:(.text+0x641): undefined reference to `gliReadTGA(_IO_FILE*, char*)'
collect2: ld returned 1 exit status
make: *** [cubemap] Error 1

which i find bizzar. Furthermore when i tried to use the previous makefile, i still had the ablve mistake in compiling. What could be the problem?


Comments

  • From what I have seen, the library glui was not added in linking:

    [color=Blue]g++ -Wall -o cubemap -mtune=generic cubemap.o tga.o -lglut -lGLU -lGL -L/usr/X11R6/lib -lXext -lX11 -lm[/color]

    See? It is not there. Maybe you have saved the Makefile to a different location?

    : Hello. i made a program on linux for opengl and i made a makefile
    : like this:
    :
    :
    : ############################################
    : GLIBS = -lglut -lGLU -lGL
    : XLIBS = -L/usr/X11R6/lib -lXext -lX11
    :
    : cubemap : cubemap.o tga.o
    : g++ -Wall -o $@ -mtune=generic cubemap.o tga.o $(GLIBS) $(XLIBS) -lm
    :
    : cubemap.o : cubemap.c tga.h
    : g++ -Wall -c cubemap.c
    :
    : tga.o : tga.c tga.h
    : g++ -Wall -c tga.c
    :
    : clean:
    : /bin/rm -f cubemap.o tga.o cubemap
    : ############################################
    :
    :
    : My program worked fine. But when i wanted to add (glui) menu, i
    : changed slightly the above makefile into this:
    :
    :
    : ############################################################
    : #new Makefile
    :
    : GLIBS = -lglui -lglut -lGLU -lGL
    : XLIBS = -L/usr/X11R6/lib -lXext -lX11
    :
    : cubemap : cubemap.o tga.o
    : g++ -Wall -o $@ -mtune=generic cubemap.o tga.o $(GLIBS) $(XLIBS) -lm
    :
    : cubemap.o : cubemap.c tga.h
    : g++ -Wall -c cubemap.c
    :
    : tga.o : tga.c tga.h
    : g++ -Wall -c tga.c
    :
    : clean:
    : /bin/rm -f cubemap.o tga.o cubemap
    :
    : ##########################################################
    :
    : Then i had this mistake:
    :
    : g++ -Wall -c cubemap.c
    : g++ -Wall -o cubemap -mtune=generic cubemap.o tga.o -lglut -lGLU
    : -lGL -L/usr/X11R6/lib -lXext -lX11 -lm
    : cubemap.o: In function `main':
    : cubemap.c:(.text+0x641): undefined reference to
    : `gliReadTGA(_IO_FILE*, char*)'
    : collect2: ld returned 1 exit status
    : make: *** [cubemap] Error 1
    :
    : which i find bizzar. Furthermore when i tried to use the previous
    : makefile, i still had the ablve mistake in compiling. What could be
    : the problem?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion