• 7034阅读
  • 5回复

编译opengl程序时出错 [复制链接]

上一主题 下一主题
离线godsapple
 

只看楼主 倒序阅读 楼主  发表于: 2006-09-27
编译opengl程序时出错
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
不知道怎么回事,原来可以编译的程序现在保错了,感觉找不到opengl模块了,如何修复呢?望解答。
g++ -c -pipe -Wall -W -O2 -g -march=i386 -mcpu=i686 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPOR
T -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o main.o main.cpp
g++ -c -pipe -Wall -W -O2 -g -march=i386 -mcpu=i686 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPOR
T -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o nehewidget.o nehewidget.
cpp
/usr/lib/qt-3.3/bin/moc nehewidget.h -o moc_nehewidget.cpp
g++ -c -pipe -Wall -W -O2 -g -march=i386 -mcpu=i686 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPOR
T -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o moc_nehewidget.o moc_neh
ewidget.cpp

g++ -o lesson01 main.o nehewidget.o moc_nehewidget.o   -L/usr/lib/qt-3.3/lib -L/usr/X11R6/lib -l
qt-mt -lXext -lX11 -lm
nehewidget.o(.text+0x29e): In function `NeHeWidget::initializeGL()':
/root/Desktop/lesson01/nehewidget.cpp:39: undefined reference to `glShadeModel'
nehewidget.o(.text+0x2b7):/root/Desktop/lesson01/nehewidget.cpp:40: undefined reference to `glCle
arColor'
nehewidget.o(.text+0x2c1):/root/Desktop/lesson01/nehewidget.cpp:41: undefined reference to `glCle
arDepth'
nehewidget.o(.text+0x2cd):/root/Desktop/lesson01/nehewidget.cpp:42: undefined reference to `glEna
ble'
nehewidget.o(.text+0x2d9):/root/Desktop/lesson01/nehewidget.cpp:43: undefined reference to `glDep
thFunc'
nehewidget.o(.text+0x2ee):/root/Desktop/lesson01/nehewidget.cpp:44: undefined reference to `glHin
t'
nehewidget.o(.text+0x30e): In function `NeHeWidget::paintGL()':
/root/Desktop/lesson01/nehewidget.cpp:49: undefined reference to `glClear'
nehewidget.o(.text+0x34d): In function `NeHeWidget::resizeGL(int, int)':
/root/Desktop/lesson01/nehewidget.cpp:59: undefined reference to `glViewport'
nehewidget.o(.text+0x359):/root/Desktop/lesson01/nehewidget.cpp:60: undefined reference to `glMat
rixMode'
nehewidget.o(.text+0x35e):/root/Desktop/lesson01/nehewidget.cpp:61: undefined reference to `glLoa
dIdentity'
nehewidget.o(.text+0x39f):/root/Desktop/lesson01/nehewidget.cpp:62: undefined reference to `gluPerspective'
nehewidget.o(.text+0x3ab):/root/Desktop/lesson01/nehewidget.cpp:63: undefined reference to `glMatrixMode'
nehewidget.o(.text+0x314): In function `NeHeWidget::paintGL()':
/root/Desktop/lesson01/nehewidget.cpp:50: undefined reference to `glLoadIdentity'
nehewidget.o(.text+0x3b6): In function `NeHeWidget::resizeGL(int, int)':
/root/Desktop/lesson01/nehewidget.cpp:64: undefined reference to `glLoadIdentity'
collect2: ld returned 1 exit status
make: *** [lesson01] 错误 1
[ 此贴被XChinux在2006-10-09 13:11重新编辑 ]
离线wjfree
只看该作者 1楼 发表于: 2006-09-27
打开该文件夹下的 *.pro文件添加 QT += opengl
离线godsapple

只看该作者 2楼 发表于: 2006-09-28
我试过了,还是不行。
离线godsapple

只看该作者 3楼 发表于: 2006-09-28
问题解决了,我在*.pro中加了一条:CONFIG+= qt opengl warn_on release
再qmake再make,生成可执行文件,运行正常。
第一次编译Nehe的opengl程序,我是按qmake -project,再qmake,再make的步骤来搞的,运行正常,现在不知道是什么回事,要手工改*.pro,我想可能是qmake出了问题,现在还在摸索,望有类似经历的朋友指点一二。
离线godsapple

只看该作者 4楼 发表于: 2006-09-28
刚才看了http://www.qiliang.net里的qmake用户手册,了解了一些qmake的知识,想试着改一下qmake的设置,让编译opengl程序的时候,不用人工改*.pro文件,而由系统自动添加opengl的配置信息,我的方法是到qt文件夹里,找到mkspecs文件夹,里面有针对不同系统的配置文件,找到default文件夹,里面有qmake.conf文件,打开该文件,在CONFIG那项加入opengl,如:CONFIG+= qt warn_on release incremental link_prl opengl
现在就不用再人工改*.pro了。
离线ihm99045
只看该作者 5楼 发表于: 2008-08-12
試了樓上的方法
還是不行呢
不過也謝謝了
快速回复
限100 字节
 
上一个 下一个