Compilation of OpenGL Redbook sample code
2014-06-30 20:28
351 查看
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
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
相关文章推荐
- Corporation of cuda and openGL Texture( Source Code sample)
- Book Contents Reviews Notes Errata Articles Talks Downloads Resources Code Formatter Cover of C# in Depth Order now (3rd edition) Implementing the Singleton Pattern in C#
- OpenGL Red Book的一个例子代码 crash
- how to `make` the src code of APUE book
- 【RefactoringCode】The description of the refactoring book
- 《ShaderX3-Advanced Rendering with DirectX and OpenGL book+code》下载
- OpenGL Programming Guide- Red Book 例子程序库 -系列- 2-Introduction to OpenGL-Part2
- GCC编译连接c++代码的四个阶段(Four stages of GCC compilation of C++ code)
- Sample Classification Code of CIFAR-10 in Torch
- 【RefactoringCode】The description of the refactoring book
- Analysing the ASM code of a simple sample of C programming language at Linux Platform by GCC and GDB
- OpenGL Programming Guide- Red Book 例子程序库 -系列- 3-Chapter 2Drawing Geometric Objects-Part1
- 细分球代码 (参考opengl redbook 的第二章)
- Python sample code of hudson remote api, my first Python hello world
- sample code of webview
- OpenGL Programming Guide- Red Book 例子程序库 -系列- 0
- BookNote: Refactoring - Improving the Design of Existing Code
- OpenGL Programming Guide (Red Book)——坐标变换
- 著名的安装制作软件InnoSetup的源码及示例源码-The installation of a well-known software s source code and sample InnoSetup source
- A real example of vioplot in R (sample data and code attached)