Compilation of OpenGL Redbook sample code

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

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): [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

Compilation of OpenGL Redbook sample code

时间: 2024-08-28 10:11:31

Compilation of OpenGL Redbook sample code的相关文章

如何将经纬度利用Google Map API显示C# VS2005 Sample Code

原文 如何将经纬度利用Google Map API显示C# VS2005 Sample Code 日前写了一篇如何用GPS抓取目前所在,并回传至资料库储存,这篇将会利用这些回报的资料,将它显示在地图上,这个做法有两种,最简单的就是直接传值到Google Maps上. 举例来说,当我们知道经纬度后,只要将数据套到以下网址即可. http://maps.google.com/maps?q=25.048346%2c121.516396 在参数q=后面,就可以加上经纬度了. 25.048346是Lati

sample code /calculate PI (转)

using System; using System.Math; namespace PiWithMonteCarlo { /// <summary> /// Trivial, synchronous calculation algorithm /// </summary> public static class TrivialPiCalculator { public static double Calculate(int iterations) { int inCircle =

sqoop sample code

本文使用的数据库是mysql的sample database employees. download url:https://launchpad.net/test-db/employees-db-1/1.0.6 然后根据ReadMe安装到自己的mysql数据库中. sqoop的安装: 下载地址:http://apache.dataguru.cn/sqoop/1.4.6/ sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz sqoop-1.4.6.tar.gz 我

lua sample code analysis

What is a meta table a meta table has a __name attr whose value is name of metatable a meta table is stored in LUA_REGISTRYINDEX whose key is its name Code analysis Appl DUMP_STACK(L); /*{ "foo", "C:\\jshe\\codes\\mylualib\\test\\../build/v

opengl redbook Fatal Error in XXXXXX pixel format with necessary capabilities not found

随便运行书中的一个程序aaindex.c时出现了下面的错误:pixel format with necessary capabilities not found 解决方法: http://www.educity.cn/wenda/519354.html http://blog.csdn.net/cyningsun/article/details/7013744 http://blog.csdn.net/lj695242104/article/details/14162183 最终将  glutI

使用MD5將字串加密 C# VS2005 Sample Code

MD5的加密已經出來很長一段時間了,也不是什麼特別的新技術,寫這篇的用意也有點像是給自己的一個Note,畢竟加密的功能不常用,最多寫成一個Class,未來去呼叫就好,怕自己也會忘記,所以把這個寫下來. 初步的UI設定如下: H執行是單純加密,而Salt執行則是跑Salted Hash的動作. 單純加密比較不好,如果被人猜到加密方法是採MD5,也沒有Salted,那會風險會高一點,而Salt的效果,因為多了一個Value去加密,除了前面的都要猜到外,還要知道Salted Value才可以.而Sal

python参数Sample Code

import time import datetime import getopt import sys try: opts, args = getopt.getopt(sys.argv[1:], "ho:", ["inputOCR=", "inputSpeech="]) except getopt.GetoptError: print ('Getopt Error!') sys.exit(1) for name, value in opts:

Stylecop code sample

StyleCopanalyzes C# source code to enforce a set of style and consistency rules. It can be run from inside of Visual Studio or integrated into an MSBuild project. StyleCop has also been integrated into many third-party development tools. StyleCop inc

OpenGL

https://www.opengl.org/resources/libraries/glut/glut_downloads.phpAbout GLUT . . .GLUT (pronounced like the glut in gluttony) is the OpenGL Utility Toolkit, a window system independent toolkit for writing OpenGL programs. It implements a simple windo