Linux下搭建Qt+OpenGL .

測試了一天,終於能在Linux的QT環境下編寫OpenGL程序了。

我原先認爲Linux下的qt跟windows下的qt一樣,裝好qt後,openGL的庫也裝好了。只要包含頭文件,就可以調用openGL的函數了。事實上,Linux的qt creator安裝好後,雖然包含有openGL的頭文件,但openGL庫函數模塊並沒有包括在其中,還需另外安裝。

Ubuntu下安裝openGL庫:

sudo apt-get install libgl-dev libglu-dev

我終端輸如後提示

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libgl-dev is a virtual package provided by:
libgl1-mesa-swx11-dev 7.7.1-1ubuntu3
libgl1-mesa-dev 7.7.1-1ubuntu3
You should explicitly select one to install.
E: Package libgl-dev has no installation candidate

libgl1-mesa-swx11-dev 7.7.1-1ubuntu3
libgl1-mesa-dev 7.7.1-1ubuntu3

libgl1-mesa-dev: it is capable of
both direct and indirect rendering. For direct rendering, it can use DRI
modules from the libgl1-mesa-dri package to accelerate drawing.


libgl1-mesa-swx11-dev: This library provides a pure software rasteriser; it does not provide
a direct rendering-capable library, or one which uses GLX. For that,
please see libgl1-mesa-dev.
安裝好庫之後,openGL程序還會出現許多"undefined reference..."
網上看到說要:在*.pro中加了一條:CONFIG+= qt opengl warn_on release
我的做法是在*.pro中使 QT += opengl ,這樣也能實現
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章