Compilation of OpenGL Redbook sample code

Source: Internet
Author: User

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

[Email protected]:~/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

And how to modify Makefile?

#
# Copyright (c) 1993-1997, Silicon Graphics, Inc.
# All Rights RESERVED
# Permission to use, copy, modify, and distribute the software for
# any purpose and without fee are 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. is 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): [Email protected]
CC [EMAIL protected] $ (lldlibs)-o [email protected]

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 [email protected] $ (lldlibs)-o [email protected]

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.