all gone

          all gone

          Linux下編寫OpenGL程序的一些準(zhǔn)備工作

          linux下編寫OpenGL程序的一些準(zhǔn)備工作

          需要用到的軟件包有兩個(gè),glut 和tmake,分別可以從以下兩個(gè)網(wǎng)址下載:
          http://www.opengl.org/resources/libraries/glut/glut-3.7.tar.gz
          ftp://ftp.trolltech.com/freebies/tmake/tmake-1.8.tar.gz

          下載后的文件假設(shè)都放在/usr/src中

          首先是安裝glut庫,以下是從www.linux.com找到的編譯glut庫的手冊(cè)。

          Install GLUT 3.7 Distribution (optional)

          If you installed the MesaDemos/MesaLib package, then you have already installed GLUT 3.7 since it is included with MesaDemos. However, you may be interested in installing the GLUT

          manpages and you can skip right to the "Install GLUT manual pages", below ...

          Installing GLUT is a bit tricky. I'm not too familiar with imake, the program that it uses to manage the Makefiles, and didn't quite see how to get GLUT to install to where I wanted it (/usr/lib,

          but MesaDemos will do this without any trouble though). It can be done manually anyhow:

           cd /usr/src
           tar -xvzf glut-3.7.tar.gz
           cd glut-3.7

           Read the file: README.linux
           cd linux
           READ the file: README
           cp Glut.cf ..
           cd ..
           Edit Glut.cf: remove any Mesa references.
           Replace any -lMesaGL -lMesaGLU with -lGL -lGLU if needed.
           In particular, replace:
            OPENGL = $(TOP)/../lib/libMesaGL.so
            GLU = $(TOP)/../lib/libMesaGLU.so
           with:
            OPENGL = -lGL
            GLU = -lGLU

           ./mkmkfiles.imake
           cd lib/glut
           cp /usr/src/glut-3.7/linux/Makefile .
           Edit the Makefile: remove any Mesa references.
           Replace any -lMesaGL -lMesaGLU with -lGL -lGLU if needed.
           In particular, replace:
            OPENGL = $(TOP)/../lib/libMesaGL.so
            GLU = $(TOP)/../lib/libMesaGLU.so
           with:
            OPENGL = -lGL
            GLU = -lGLU

           make
           ln -s libglut.so.3.7 libglut.so
           ln -s libglut.so.3.7 libglut.so.3
           cp -d libglut.* /usr/lib
           cd ..
           cd gle
           # make a shared lib for libgle
           make
           gcc -shared -o libgle.so.3.7 *.o
           ln -s libgle.so.3.7 libgle.so
           ln -s libgle.so.3.7 libgle.so.3
           cp -d libgle.* /usr/lib
           cd ..
           cd mui
           # make a shared lib for libmui
           make
           gcc -shared -o libmui.so.3.7 *.o
           ln -s libmui.so.3.7 libmui.so
           ln -s libmui.so.3.7 libmui.so.3
           cp -d libmui.* /usr/lib

                  # Install the GLUT manual pages (not included with MesaDemos)
           cd /usr/src/glut-3.7
           make SUBDIRS=man Makefile
           cd man/glut
           make install.man
           ldconfig

           cd ../../progs/demos/ideas
           # edit the Makefile, change OPENGL = -lGL and GLU = -lGLU
           make
           ./ideas
           # test compiling some demos
           # take a look at which libraries have to be linked (-lX11 ...) in
           # the Makefiles.  Qt's tmake program available at www.troll.no
           # is a quick way to make a Makefile but you have to edit it
           # and add the -l needed.
          ideas如果運(yùn)行成功的話,說明glut已經(jīng)可以用了,這時(shí)可以將include/GL下的glut等頭文件復(fù)制到/usr/include中去。

          上面的幾步中,下載的glut包放在/usr/src目錄下,如果放在其他目錄下,將/usr/src改為相應(yīng)的目錄即可。
          此外應(yīng)該注意的是兩個(gè)Makefile文件的修改
           改 
          ·  OPENGL = $(TOP)/../lib/libMesaGL.so
            GLU = $(TOP)/../lib/libMesaGLU.so
           為
            OPENGL = -lGL
            GLU = -lGLU
          因?yàn)樗付ǖ哪夸浿袥]有l(wèi)ibMesaGL.so和libMesaGLU.so。

          之后是tmake的配置,后面我們可以用它來生成pro工程文件和makefile文件。

          先將下載的tmake解壓縮,tar  -zxvf  tmake-1.8.tar.gz
          得到tmake-1.8目錄,之后設(shè)置兩個(gè)環(huán)境變量:PATH和TMAKEPATH
          PATH=$PATH:/usr/src/tmake-1.8/bin
          export PATH
          TMAKEPATH=/usr/src/tmake-1.8/lib/linux-g++
          export TMAKEPATH

          新建一個(gè)測試目錄test,將glut-3.7目錄下的progs/redbook目錄下的hello.c復(fù)制到test目錄中

          之后生成一個(gè)pro文件:progen  -o hello.pro

          然后生成makefile文件:tmake hello.pro -o Makefile

          編輯生成的Makefile文件,在加載動(dòng)態(tài)連接庫的行里面加入 -lglut -lXi -lXmu

          保存,make。

          ./hello 可以看到運(yùn)行結(jié)果就可以了。

          posted on 2005-12-09 19:22 all gone 閱讀(633) 評(píng)論(0)  編輯  收藏 所屬分類: Unix & Linux 、OpenGL

          主站蜘蛛池模板: 华安县| 聊城市| 仪陇县| 六盘水市| 蛟河市| 桂平市| 江安县| 寻甸| 玉龙| 阿合奇县| 嘉义市| 布拖县| 理塘县| 都昌县| 亳州市| 波密县| 阳江市| 富阳市| 清镇市| 武夷山市| 乌苏市| 佛山市| 宽甸| 淮滨县| 延川县| 诸暨市| 常宁市| 吴旗县| 昌吉市| 通化市| 临沭县| 韶关市| 武胜县| 北流市| 安康市| 拉萨市| 翁牛特旗| 馆陶县| 镇坪县| 沙洋县| 商丘市|