Compilation of OpenGL Redbook sample code

 

 

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

 

 

转载于:https://www.cnblogs.com/kylegui/p/3817237.html

--- 在此連線階段时请选用CRAN的鏡子 --- also installing the dependency ‘DBI’ Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘ROracle’ 你想从源代码尝试安装这些 y/n: y 试开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/3.2/DBI_0.3.1.zip' Content type 'application/zip' length 162901 bytes (159 KB) downloaded 159 KB 程序包‘DBI’打开成功,MD5和检查也通过 下载的二进制程序包在 C:\Documents and Settings\Administrator\Local Settings\Temp\RtmpA35ab3\downloaded_packages里 installing the source package ‘ROracle’ 试开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/ROracle_1.2-1.tar.gz' Content type 'application/octet-stream' length 299072 bytes (292 KB) downloaded 292 KB * installing *source* package 'ROracle' ... ** 成功将'ROracle'程序包解包并MD5和检查 ERROR: cannot find Oracle Client. Please set OCI_LIB32 to specify its location. Warning: 运行命令'sh ./configure.win'的状态是1 ERROR: configuration failed for package 'ROracle' * removing 'C:/R-3.2.2/library/ROracle' 下载的程序包在 ‘C:\Documents and Settings\Administrator\Local Settings\Temp\RtmpA35ab3\downloaded_packages’里 Warning messages: 1: 运行命令'"C:/R-3.2.2/bin/i386/R" CMD INSTALL -l "C:\R-3.2.2\library" C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RtmpA35ab3/downloaded_packages/ROracle_1.2-1.tar.gz'的状态是1 2: In install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : 安装程序包‘ROracle’时退出狀態的值不是0 上面是界面里面显示的东西,上面流程走完之后还是LIBRARY还是无法找到包,求大婶帮帮忙啊!!!!!
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符 “速评一下”
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页