all gone

          all gone

          Linux下編寫OpenGL程序的一些準備工作

          linux下編寫OpenGL程序的一些準備工作

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

          下載后的文件假設都放在/usr/src中

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

          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如果運行成功的話,說明glut已經可以用了,這時可以將include/GL下的glut等頭文件復制到/usr/include中去。

          上面的幾步中,下載的glut包放在/usr/src目錄下,如果放在其他目錄下,將/usr/src改為相應的目錄即可。
          此外應該注意的是兩個Makefile文件的修改
           改 
          ·  OPENGL = $(TOP)/../lib/libMesaGL.so
            GLU = $(TOP)/../lib/libMesaGLU.so
           為
            OPENGL = -lGL
            GLU = -lGLU
          因為所指定的目錄中沒有libMesaGL.so和libMesaGLU.so。

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

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

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

          之后生成一個pro文件:progen  -o hello.pro

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

          編輯生成的Makefile文件,在加載動態連接庫的行里面加入 -lglut -lXi -lXmu

          保存,make。

          ./hello 可以看到運行結果就可以了。

          posted on 2005-12-09 19:22 all gone 閱讀(636) 評論(0)  編輯  收藏 所屬分類: Unix & LinuxOpenGL

          主站蜘蛛池模板: 民县| 竹溪县| 仁寿县| 鞍山市| 龙门县| 泗洪县| 华宁县| 马关县| 桃园市| 崇文区| 广西| 会宁县| 历史| 湄潭县| 广东省| 平湖市| 喀喇沁旗| SHOW| 尼木县| 商河县| 侯马市| 昆明市| 吉安市| 柯坪县| 长泰县| 米林县| 五寨县| 定南县| 红河县| 万荣县| 永康市| 深圳市| 宝鸡市| 藁城市| 东乌珠穆沁旗| 韶关市| 津市市| 桃江县| 长葛市| 临朐县| 石门县|