PDA

View Full Version : why linking problem with QGLWidget???



Shuchi Agrawal
14th March 2007, 12:38
hi all,
i have included <QGLWidget> in my program but while make, its giving a problem as :
In file included from form.h:5,
from form.cpp:2:
glwidget.h:5:21: error: QGLWidget: No such file or directory
glwidget.h:8: error: expected class-name before ‘{’ token
glwidget.h:36: error: ‘GLuint’ does not name a type
glwidget.h:37: error: ‘GLdouble’ has not been declared
glwidget.h:37: error: ‘GLdouble’ has not been declared
glwidget.h:37: error: ‘GLdouble’ has not been declared
glwidget.h:37: error: ‘GLdouble’ has not been declared
glwidget.h:38: error: ‘GLdouble’ has not been declared
glwidget.h:38: error: ‘GLdouble’ has not been declared
glwidget.h:38: error: ‘GLdouble’ has not been declared
glwidget.h:38: error: ‘GLdouble’ has not been declared
glwidget.h:39: error: ‘GLdouble’ has not been declared
glwidget.h:39: error: ‘GLdouble’ has not been declared
glwidget.h:39: error: ‘GLdouble’ has not been declared
glwidget.h:39: error: ‘GLdouble’ has not been declared
glwidget.h:42: error: ‘GLuint’ does not name a type
glwidget.h:8: warning: ‘class GLWidget’ has virtual functions but non-virtual destructor
form.cpp: In constructor ‘MainWindow::MainWindow(QMainWindow*)â€℠¢:
form.cpp:41: error: ‘class GLWidget’ has no member named ‘setGeometry’
make: *** [form.o] Error 1
[root@localhost 2and3D]#

though i have include QT += opengl in .pro file (is there any implicit way to include this using qmake???)
and all the files are there in the Qt installation directory as they are on indos too. no file is missing. all paths are set.. only the QGLWidget thing is giving problem.
Can any1 tel me that is it a diff way to do the same on linux coz the same is working properly on windows.
Thanks

high_flyer
14th March 2007, 12:46
try:
#include <QtOpenGL/QGLWidget>

jpn
14th March 2007, 12:47
though i have include QT += opengl in .pro file
Have you re-run qmake after modifying to .pro file? The makefiles have to be regenerated after modifying the .pro so that correct include directories and library linkings are set.

Shuchi Agrawal
15th March 2007, 03:52
try:
#include <QtOpenGL/QGLWidget>
this is also not working.
And J-P N, i have done "qmake" after changing .pro file n then "make".
after including #include <QtOpenGL/QGLWidget>, i m getting the error :
In file included from form.h:5,
from form.cpp:2:
glwidget.h:5:30: error: QtOpenGL/QGLWidget: No such file or directory
glwidget.h:8: error: expected class-name before ‘{’ token
glwidget.h:36: error: ‘GLuint’ does not name a type
....
glwidget.h:39: error: ‘GLdouble’ has not been declared
glwidget.h:42: error: ‘GLuint’ does not name a type
glwidget.h:8: warning: ‘class GLWidget’ has virtual functions but non-virtual destructor
form.cpp: In constructor ‘MainWindow::MainWindow(QMainWindow*)â€℠¢:
form.cpp:41: error: ‘class GLWidget’ has no member named ‘setGeometry’
make: *** [form.o] Error 1
[root@localhost 2and3D]#

Please see to it because i am unable to find the point where i m wrong.
Thanks

vermarajeev
15th March 2007, 04:15
If you are using makefiles, Qt include paths should be set automatically when you install. If they are not, make sure you use the INCLUDEPATH variable within your project file, or set appropriate environment variables.

Thanks

jpn
15th March 2007, 07:12
i have done "qmake" after changing .pro file n then "make".
after including #include <QtOpenGL/QGLWidget>, i m getting the error :
Could you show the full compiler command with all the arguments?

high_flyer
15th March 2007, 10:02
Do you have both Qt3 and Qt4 installed?
It could be that the qmake of Qt3 is called.

Shuchi Agrawal
15th March 2007, 10:54
Do you have both Qt3 and Qt4 installed?
It could be that the qmake of Qt3 is called.

yes, both are installed because Qt3 came with fedora core 5 and i installed Qt4.2.2. but i want Qt4.2.2 to work in every case. how can i do that?

high_flyer
15th March 2007, 11:03
one quick way to fix it is to change the order of the Qt3 and Qt4 paths in your PATH variable.
Have the Qt4 path be first.
You might want to check that LD_LIBRARY_PATH knows where your Qt4 libs are.
End you should change your signature, since you are on Fedora and not XP ;)

Shuchi Agrawal
15th March 2007, 11:07
Could you show the full compiler command with all the arguments?

My commands are :
[application directory]#qmake -project
then i edit the .pro file and add QT += opengl
[application directory]#qmake
[application directory]#make
then i get all errors which i have mentioned.

high_flyer
15th March 2007, 11:15
what jpn meant is the print out of the your make file - when you run make, you see in the console the commands make is running.
We need the first command that makes runs.
it looks similar to this:


g++ -c -Wall -W -O2 -fPIC -DQT_SHARED -DQT_NO_DEBUG -DQT_NO_NIS
-DQT_NO_XINERAMA -DQT_NO_XRENDER -DQT_NO_XFTFREETYPE -DQT_NO_XKB -DQT_NO_REMOTE
-DQT_NO_IMAGEIO_MNG -DQT_NO_IMAGEIO_JPEG -DQT_NO_STYLE_AQUA -DQT_NO_STYLE_MAC
-DQT_NO_STYLE_INTERLACE -DQT_NO_STYLE_COMPACT -I3rdparty/libpng -I3rdparty/zlib
-I/usr/local/qt/include -I../../../include -I../../../include -I/usr/local/qt/mkspecs/

Also you might want to look at this: http://doc.trolltech.com/4.2/qmake-environment-reference.html

Shuchi Agrawal
15th March 2007, 11:36
Could you show the full compiler command with all the arguments?

[root@localhost 2and3D]# qmake -project
//changed .pro file and added QT += opengl
[root@localhost 2and3D]# qmake
[root@localhost 2and3D]# make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/root/qt-x11-opensource-src-4.2.2/mkspecs/linux-g++ -I. \
-I/usr/local/Trolltech/Qt-4.2.2/include/QtCore -I/usr/local/Trolltech/Qt-4.2.2/include/QtCore -I/usr/local/Trolltech/Qt-4.2.2/include/QtGui \
-I/usr/local/Trolltech/Qt-4.2.2/include/QtGui -I/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.2.2/include -I. -I/usr/X11R6/include -I. -I. -o form.o form.cpp
In file included from form.h:5,
from form.cpp:2:
glwidget.h:5:30: error: QtOpenGL/QGLWidget: No such file or directory
glwidget.h:8: error: expected class-name before ‘{’ token
glwidget.h:36: error: ‘GLuint’ does not name a type
glwidget.h:37: error: ‘GLdouble’ has not been declared
glwidget.h:37: error: ‘GLdouble’ has not been declared
glwidget.h:37: error: ‘GLdouble’ has not been declared
glwidget.h:37: error: ‘GLdouble’ has not been declared
glwidget.h:38: error: ‘GLdouble’ has not been declared
glwidget.h:38: error: ‘GLdouble’ has not been declared
glwidget.h:38: error: ‘GLdouble’ has not been declared
glwidget.h:38: error: ‘GLdouble’ has not been declared
glwidget.h:39: error: ‘GLdouble’ has not been declared
glwidget.h:39: error: ‘GLdouble’ has not been declared
glwidget.h:39: error: ‘GLdouble’ has not been declared
glwidget.h:39: error: ‘GLdouble’ has not been declared
glwidget.h:42: error: ‘GLuint’ does not name a type
glwidget.h:8: warning: ‘class GLWidget’ has virtual functions but non-virtual destructor
form.cpp: In constructor ‘MainWindow::MainWindow(QMainWindow*)â€℠¢:
form.cpp:41: error: ‘class GLWidget’ has no member named ‘setGeometry’
make: *** [form.o] Error 1
[root@localhost 2and3D]#

[root@localhost ~]# env
SSH_AGENT_PID=2598
HOSTNAME=localhost.localdomain
DESKTOP_STARTUP_ID=
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
GTK_RC_FILES=/etc/gtk/gtkrc:/root/.gtkrc-1.2-gnome2
WINDOWID=41950507
QTDIR=/root/qt-x11-opensource-src-4.2.2
QTINC=/root/qt-x11-opensource-src-4.2.2/include
USER=root
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:s o=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi= 01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com =00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00 ;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;3 1:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz =00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00; 31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;3 5:\
*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
GNOME_KEYRING_SOCKET=/tmp/keyring-lB9HNn/socket
SSH_AUTH_SOCK=/tmp/ssh-TkJpfF2555/agent.2555
KDEDIR=/usr
SESSION_MANAGER=local/localhost.localdomain:/tmp/.ICE-unix/2555
MAIL=/var/spool/mail/root
DESKTOP_SESSION=default
PATH=/root/qt-x11-opensource-src-4.2.2/bin:/root/qt-x11-opensource-src-4.2.2/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:\
/usr/X11R6/bin:/root/qt-x11-opensource-src-4.2.2/bin:/root/bin
GDM_XSERVER_LOCATION=local
INPUTRC=/etc/inputrc
PWD=/root
LANG=en_US.UTF-8
QMAKESPEC=/root/qt-x11-opensource-src-4.2.2/mkspecs/linux-g++
GDMSESSION=default
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HOME=/root
SHLVL=2
GNOME_DESKTOP_SESSION_ID=Default
LOGNAME=root
QTLIB=/root/qt-x11-opensource-src-4.2.2/lib
CVS_RSH=ssh
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-XG0E1vGhF5,guid=752ef945ca242e50a5d2bb9767ffcd00
LESSOPEN=|/usr/bin/lesspipe.sh %s
DISPLAY=:0.0
G_BROKEN_FILENAMES=1
COLORTERM=gnome-terminal
XAUTHORITY=/root/.Xauthority
_=/bin/env
[root@localhost ~]#

high_flyer
15th March 2007, 11:48
well first, you can take QtOpenGL from the include line since qmake adds it ok:

-I/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL
If this doesn't work, it means you didn't install Qt with openGL support.
Wait a minute, is this where your Qt4 is?:

QTDIR=/root/qt-x11-opensource-src-4.2.2
QTINC=/root/qt-x11-opensource-src-4.2.2/include

vermarajeev
15th March 2007, 12:13
I think the problem is here..
/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL---> compiler is serching this path
QTDIR=/root/qt-x11-opensource-src-4.2.2 ---> Qt is installed here.
QTINC=/root/qt-x11-opensource-src-4.2.2/include ---> Takes this PATH to include

I think you need to change the environment settings or uninstall and reinstall Qt again:)

Shuchi Agrawal
16th March 2007, 07:41
hi all,
i reinstalled Qt with option -opengl but in the end of ./configure -prefix-install - opengl it gave as :
...
rm -f libQtSvg.so.4.2.2 libQtSvg.so libQtSvg.so.4 libQtSvg.so.4.2
g++ -Wl,-rpath,/usr/local/Trolltech/Qt-4.2.2/lib -Wl,-rpath,/usr/local/Trolltech/Qt-4.2.2/lib -shared -Wl,-soname,libQtSvg.so.4 -o libQtSvg.so.4.2.2 .obj/release-shared/qsvggraphics.o .obj/release-shared/qsvghandler.o .obj/release-shared/qsvgnode.o .obj/release-shared/qsvgstructure.o .obj/release-shared/qsvgstyle.o .obj/release-shared/qsvgfont.o .obj/release-shared/qsvgtinydocument.o .obj/release-shared/qsvgrenderer.o .obj/release-shared/qsvgwidget.o .obj/release-shared/qgraphicssvgitem.o .obj/release-shared/moc_qsvgwidget.o -L/usr/local/Trolltech/Qt-4.2.2/lib -lQtXml -L/usr/local/Trolltech/Qt-4.2.2/lib -lQtGui -L/usr/X11R6/lib -lpng -lSM -lICE -lXrender -lXrandr -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -lglib-2.0 -lpthread -ldl
ln -s libQtSvg.so.4.2.2 libQtSvg.so
ln -s libQtSvg.so.4.2.2 libQtSvg.so.4
ln -s libQtSvg.so.4.2.2 libQtSvg.so.4.2
rm -f ../../lib/libQtSvg.so.4.2.2
rm -f ../../lib/libQtSvg.so
rm -f ../../lib/libQtSvg.so.4
rm -f ../../lib/libQtSvg.so.4.2
mv -f libQtSvg.so.4.2.2 libQtSvg.so libQtSvg.so.4 libQtSvg.so.4.2 ../../lib/
(test -z "../../lib/" || cd "../../lib/" ; targ=`basename libQtSvg.so.4.2.2`; objcopy --only-keep-debug "$targ" "$targ.debug" && objcopy --strip-debug "$targ" && objcopy --add-gnu-debuglink="$targ.debug" "$targ" && chmod -x "$targ.debug" ) ;
gmake[2]: Leaving directory `/usr/local/Trolltech/Qt-4.2.2/src/svg'
cd opengl && gmake -f Makefile
gmake[2]: Entering directory `/usr/local/Trolltech/Qt-4.2.2/src/opengl'
/usr/local/Trolltech/Qt-4.2.2/bin/qmake -spec ../../mkspecs/linux-g++ -unix -o Makefile opengl.pro
gmake[2]: Leaving directory `/usr/local/Trolltech/Qt-4.2.2/src/opengl'
gmake[2]: Entering directory `/usr/local/Trolltech/Qt-4.2.2/src/opengl'
g++ -c -pipe -g -O2 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DQT_SHARED -DQT_BUILD_OPENGL_LIB -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../mkspecs/linux-g++ -I. -I../../include/QtCore -I../../include/QtCore -I../../include/QtGui -I../../include/QtGui -I../../include -I../../include/QtOpenGL -I/usr/include/freetype2 -I/usr/X11R6/include -I/usr/X11R6/include -I.moc/release-shared -I.uic/release-shared -o .obj/release-shared/qgl.o qgl.cpp
In file included from qgl.cpp:26:
qgl.h:60:21: error: GL/glu.h: No such file or directory
../../include/QtCore/../../src/corelib/thread/qthreadstorage.h: In static member function ‘static void QThreadStorage<T>::deleteData(void*) [with T = QGLThreadContext*]’:
../../include/QtCore/../../src/corelib/thread/qthreadstorage.h:116: instantiated from ‘QThreadStorage<T>::QThreadStorage() [with T = QGLThreadContext*]’
qgl.cpp:39: instantiated from here
../../include/QtCore/../../src/corelib/thread/qthreadstorage.h:113: warning: dereferencing type-punned pointer will break strict-aliasing rules
gmake[2]: *** [.obj/release-shared/qgl.o] Error 1
gmake[2]: Leaving directory `/usr/local/Trolltech/Qt-4.2.2/src/opengl'
gmake[1]: *** [sub-opengl-make_default] Error 2
gmake[1]: Leaving directory `/usr/local/Trolltech/Qt-4.2.2/src'
gmake: *** [sub-src-make_default-ordered] Error 2
[root@localhost Qt-4.2.2]#

so after tht i did gmake and set QMAKESPEC
no when i try to run my same program with opengl as:
qmake -project
added QT += opengl in .pro file
qmake
make [or gmake]
its giving the error as
[root@localhost 2and3D]# make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.2.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.2.2/include/QtCore -I/usr/local/Trolltech/Qt-4.2.2/include/QtCore -I/usr/local/Trolltech/Qt-4.2.2/include/QtGui -I/usr/local/Trolltech/Qt-4.2.2/include/QtGui -I/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.2.2/include -I. -I/usr/X11R6/include -I. -I. -o form.o form.cpp
In file included from /usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL/qgl.h:1,
from /usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL/QGLWidget:1,
from glwidget.h:5,
from form.h:5,
from form.cpp:2:
/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL/../../src/opengl/qgl.h:60:21: error: GL/glu.h: No such file or directory
make: *** [form.o] Error 1
[root@localhost 2and3D]#
there is no "glu.h" file on my system

So i think that opengl is not installed. so can u help me that how can i install with opengl?
Thanks All..

high_flyer
16th March 2007, 09:04
error: GL/glu.h: No such file or directory
it looks like you don't have opengl installed on your system.
Make sure its installed.
When you run Qt's configure script, you should read the output configure gives, you will see there if it was able to find opengl or not. (and all other dependencied)

Shuchi Agrawal
16th March 2007, 10:11
it looks like you don't have opengl installed on your system.
Make sure its installed.
Do i need to install opengl with Qt "qt-x11-opensource-src-4.2.2.tar.gz". i mean it doesn't come with it?

When you run Qt's configure script, you should read the output configure gives, you will see there if it was able to find opengl or not. (and all other dependencied)
where can i see this configure output file.

high_flyer
16th March 2007, 10:45
you can read the configure output when you call configure in your console before you compile Qt.
If you do ./configure --help, you will get a list with all options.
One of these option is -opengl or similar.

I don't know if Qt comes with its own opengl lib src. (can't remember)
At the configure help, there is a line next to some lib options that says "use system lib" or something similar, for these libs you can choose to use either a system installed lib or to compile the lib from the Qt src.
I can't remember if opengl is like that or not.