码迷,mamicode.com
首页 > 数据库 > 详细

Compilation of OpenGL Redbook sample code

时间:2014-07-01 12:53:51      阅读:337      评论:0      收藏:0      [点我收藏+]

标签:http   color   os   cti   linux   for   

 

 

http://download.csdn.net/detail/gflytu/4110817#comment

 

kgui@linuxamd:~/Downloads/redbook$ gcc -lglut -lGL -lGLU aaindex.c

aaindex.c:(.text+0x2f7): undefined reference to `glutInit‘
aaindex.c:(.text+0x303): undefined reference to `glutInitDisplayMode‘
aaindex.c:(.text+0x317): undefined reference to `glutInitWindowSize‘
aaindex.c:(.text+0x324): undefined reference to `glutCreateWindow‘
aaindex.c:(.text+0x335): undefined reference to `glutReshapeFunc‘
aaindex.c:(.text+0x341): undefined reference to `glutKeyboardFunc‘
aaindex.c:(.text+0x34d): undefined reference to `glutDisplayFunc‘
aaindex.c:(.text+0x352): undefined reference to `glutMainLoop‘
collect2: error: ld returned 1 exit status


Then, re-install

sudo apt-get install freeglut3-dev 

Reading package lists... Done
Building dependency tree       
Reading state information... Done
freeglut3-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 158 not upgraded.

Then, use cmd below and it pass compilation

gcc teapot.c -c -lGL -lGLU -lglut

gcc aaindex.c -c -lGL -lGLU -lglut

 

Then, How to modify Makefile?

 

#
# Copyright (c) 1993-1997, Silicon Graphics, Inc.
# ALL RIGHTS RESERVED
# Permission to use, copy, modify, and distribute this software for
# any purpose and without fee is hereby granted, provided that the above
# copyright notice appear in all copies and that both the copyright notice
# and this permission notice appear in supporting documentation, and that
# the name of Silicon Graphics, Inc. not be used in advertising
# or publicity pertaining to distribution of the software without specific,
# written prior permission.
#


TARGETS = aaindex aapoly aargb accanti accpersp \
        alpha alpha3D bezcurve bezmesh bezsurf \
        clip colormat cube dof double \
        drawf feedback fog fogindex font hello \
        image light lines list material \
        model movelight pickdepth picksquare planet \
        polys quadric robot scene select \
        smooth stencil stroke surface teapots tess \
        tesswind checker mipmap \
    polyoff texbind texgen texprox texsub varray wrap \
        texturesurf torus trim unproject

LLDLIBS = -lglut -lGLU -lGL

default: $(TARGETS)

all: default

.c.o:
    cc -c -I/usr/include -I$(TOP) $<

$(TARGETS): $$@.o
    cc $@.o $(LLDLIBS) -o $@

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

 

Modified to makefile as below

 

TARGETS = aaindex aapoly aargb accanti accpersp \
        alpha alpha3D bezcurve bezmesh bezsurf \
        clip colormat cube dof double \
        drawf feedback fog fogindex font hello \
        image light lines list material \
        model movelight pickdepth picksquare planet \
        polys quadric robot scene select \
        smooth stencil stroke surface teapots tess \
        tesswind checker mipmap \
    polyoff texbind texgen texprox texsub varray wrap \
        texturesurf torus trim unproject

OBJS=$(patsubst %.c,%.o,$(SRCS))

LLDLIBS = -lglut -lGLU -lGL -lm
default: $(TARGETS)

all:default

$(TARGETS):$(OBJS)
    gcc $@.c $(LLDLIBS) -o $@

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

 

 make -f Makefile.ubuntu

gcc texbind.c -lglut -lGLU -lGL -lm  -o texbind
gcc texgen.c -lglut -lGLU -lGL -lm  -o texgen
gcc texprox.c -lglut -lGLU -lGL -lm  -o texprox
gcc texsub.c -lglut -lGLU -lGL -lm  -o texsub
gcc varray.c -lglut -lGLU -lGL -lm  -o varray
gcc wrap.c -lglut -lGLU -lGL -lm  -o wrap
gcc texturesurf.c -lglut -lGLU -lGL -lm  -o texturesurf
gcc torus.c -lglut -lGLU -lGL -lm  -o torus
gcc trim.c -lglut -lGLU -lGL -lm  -o trim
trim.c: In function ‘init’:
trim.c:110:21: warning: passing argument 3 of ‘gluNurbsCallback’ from incompatible pointer type [enabled by default]
                     nurbsError);
                     ^
In file included from /usr/include/GL/freeglut_std.h:129:0,
                 from /usr/include/GL/glut.h:17,
                 from trim.c:45:
/usr/include/GL/glu.h:319:23: note: expected ‘_GLUfuncptr’ but argument is of type ‘void (*)(GLenum)’
 GLAPI void GLAPIENTRY gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc);
                       ^
gcc unproject.c -lglut -lGLU -lGL -lm  -o unproject

 

 

Compilation of OpenGL Redbook sample code,布布扣,bubuko.com

Compilation of OpenGL Redbook sample code

标签:http   color   os   cti   linux   for   

原文地址:http://www.cnblogs.com/kylegui/p/3817237.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!