PDA

View Full Version : Opengl issue with Qt4.4.3



j0rt4g4
20th November 2008, 13:54
Hi everyone, well my problems is that I tried to do a basic aplication where I could open a OGLWidget and I says that I dont haves de #include<OGLWidget> in the defeaul folder.

So, What library shoud I open if I want to do this? (I'm using Qt4.4.3 Opensource).

And Here is my code:
jose.h



#ifndef JOSE_H
#define JOSE_H

#include <QApplication>
#include <QDialog>
#include <QPushButton>
#include <QWidget>
#include <QFont>
#include <OGLWidged> //-----Here's the "missing file"

class josewidget : public QWidget
{
public:
josewidget (QWidget *parent = 0);

//public slots:
// void repaint();

protected:
void paintEvent(QPaintEvent *event);
void repaint();
};

#endif


jose.cpp


#include "jose.h"
#include <QTime>
#include <QTimer>
#include <QPainter>
#include <QPaintEvent>
//#include <QGLWidget>

josewidget::josewidget(QWidget *parent)
: QWidget(parent)
{
//OGLwidget = new OGLWidget;

setFixedSize(400,200);
setAutoFillBackground(false);

QPushButton *ok = new QPushButton(tr("Ok"),this);
ok->setGeometry (60,40,75,30);
ok->setFont(QFont("Times",18, QFont::Bold));

QPushButton *quit = new QPushButton(tr("Salir"),this);
quit->setGeometry (150,40,165,30);
quit->setFont(QFont("Times",18, QFont::Bold));

connect(quit,SIGNAL(clicked()),qApp,SLOT(quit()));
connect(ok,SIGNAL(clicked()),qApp,SLOT(Event));

}



void josewidget::paintEvent(QPaintEvent *event)
{

unsigned long int i;
QTime time;
time.currentTime();
qsrand ((unsigned int)time.second());

QPainter painter(this);
painter.setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap));
painter.setRenderHint(QPainter::Antialiasing, true);
for(i=0;i<=100000;i++){
painter.drawPoint(qrand()%400, qrand()%300);
}
}


main.cpp:


#include "jose.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
josewidget *dialog = new josewidget;
dialog->show();
return app.exec();
}


I tried to compiled too the "hellogl" example and it says errors like this one:


http://img361.imageshack.us/img361/4238/consolatk5.th.jpg (http://img361.imageshack.us/my.php?image=consolatk5.jpg)

lyuts
20th November 2008, 14:40
No error is given!

Anyway, did you put "QT += opengl" in your pro file?

j0rt4g4
20th November 2008, 18:45
Thank you for aswering...

I did ".pro file" with command line "qmake -project", then I use "qmake" and last "make".
But i got lots and lots of mistakes for some libraries missing.

I followed this link, That was the way I "prepared" Qt:
http://sector.ynet.sk/qt4-tutorial/preparations.html

I don't know what I'm doing wrong, because I can't compile any example in folder "examples" clearly. Is there any other page where I could configure Qt better than that one?

The problem in my code is the copiler is not able to find "#include<OGLWidget" so I Could not create a "josegl = new OGLWidget". :S

lyuts
20th November 2008, 19:14
Try to do this:


qmake -project
qmake "QT += opengl" your_pro_file
make

j0rt4g4
20th November 2008, 20:06
This is What I get when I want to Add this line: "#include <OGLWidget>" in the "jose.h" and try to copile the way you said:



D:\lote3\test>dir
El volumen de la unidad D es G@mes
El número de serie del volumen es: CCAD-7665

Directorio de D:\lote3\test

20/11/2008 03:21 p.m. <DIR> .
20/11/2008 03:21 p.m. <DIR> ..
20/11/2008 03:18 p.m. 338 11.pro
20/11/2008 03:18 p.m. <DIR> debug
06/11/2008 03:54 p.m. 1.445 jose.cpp
20/11/2008 03:08 p.m. 429 jose.h
06/11/2008 12:56 p.m. 183 main.cpp
20/11/2008 03:18 p.m. 5.214 Makefile
20/11/2008 03:18 p.m. 4.647 Makefile.Debug
20/11/2008 03:18 p.m. 4.698 Makefile.Release
20/11/2008 03:11 p.m. <DIR> release
7 archivos 16.954 bytes
4 dirs 6.635.053.056 bytes libres

D:\lote3\test>qmake -project

D:\lote3\test>qmake "QT += opengl" 11.pro

D:\lote3\test>make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `D:/lote3/test'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEED
S_QMAIN -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4
.4.3\include\QtGui" -I"c:\Qt\4.4.3\include\QtGui" -I"c:\Qt\4.4.3\include\QtOpenG
L" -I"c:\Qt\4.4.3\include\QtOpenGL" -I"c:\Qt\4.4.3\include" -I"." -I"c:\Qt\4.4.3
\include\ActiveQt" -I"debug" -I"." -I"c:\Qt\4.4.3\mkspecs\win32-g++" -o debug\jo
se.o jose.cpp
In file included from jose.cpp:1:
jose.h:11:21: OGLWidget: No such file or directory
mingw32-make[1]: *** [debug/jose.o] Error 1
mingw32-make[1]: Leaving directory `D:/lote3/test'
mingw32-make: *** [debug] Error 2

:confused:

lyuts
20th November 2008, 20:39
You are including OGLWidget but it should be QGLWidget.

j0rt4g4
20th November 2008, 21:10
You are including OGLWidget
but it should be QGLWidget.

Aren't the same? How it should be ?, Well I see it has the same spelling... Capitals and all...

PD: Forget it... is "Q"GLWidget ... xD I realized :P I'm going to test it, right now!



Setting up a MinGW/Qt only environment...
-- QTDIR set to C:\Qt\4.4.3
-- PATH set to C:\Qt\4.4.3\bin
-- Adding C:\MinGW\bin to PATH
-- Adding C:\WINDOWS\System32 to PATH
-- QMAKESPEC set to win32-g++

C:\Qt\4.4.3>cd
D:\lote3\test>qmake -project
D:\lote3\test>qmake
D:\lote3\test>qmake "QT += opengl" test.pro

D:\lote3\test>make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `D:/lote3/test'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEED
S_QMAIN -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4
.4.3\include\QtGui" -I"c:\Qt\4.4.3\include\QtGui" -I"c:\Qt\4.4.3\include\QtOpenG
L" -I"c:\Qt\4.4.3\include\QtOpenGL" -I"c:\Qt\4.4.3\include" -I"." -I"c:\Qt\4.4.3
\include\ActiveQt" -I"debug" -I"." -I"c:\Qt\4.4.3\mkspecs\win32-g++" -o debug\jo
se.o jose.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEED
S_QMAIN -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4
.4.3\include\QtGui" -I"c:\Qt\4.4.3\include\QtGui" -I"c:\Qt\4.4.3\include\QtOpenG
L" -I"c:\Qt\4.4.3\include\QtOpenGL" -I"c:\Qt\4.4.3\include" -I"." -I"c:\Qt\4.4.3
\include\ActiveQt" -I"debug" -I"." -I"c:\Qt\4.4.3\mkspecs\win32-g++" -o debug\ma
in.o main.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -mthreads -Wl -Wl,-subsystem,windows -o debug\test.exe debug/jose.o debug/mai
n.o -L"c:\Qt\4.4.3\lib" -lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmaind
-lQtOpenGLd4 -lQtGuid4 -lQtCored4
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\ mingw32\bin\ld.exe: cannot fin
d -lQtOpenGLd4
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\test.exe] Error 1
mingw32-make[1]: Leaving directory `D:/lote3/test'
mingw32-make: *** [debug] Error 2

D:\lote3\test>

:o this was the response...

j0rt4g4
21st November 2008, 18:10
How I could resolve this? Anyone has an Idea?


C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\ mingw32\bin\ld.exe: cannot fin
d -lQtOpenGLd4
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\test.exe] Error 1
mingw32-make[1]: Leaving directory `D:/lote3/test'
mingw32-make: *** [debug] Error 2

jacek
21st November 2008, 19:33
It seems that you don't have the debug versions of Qt libraries. Either build them or build your application in release mode.

j0rt4g4
22nd November 2008, 03:23
I tr



Setting up a MinGW/Qt only environment...
-- QTDIR set to C:\Qt\4.4.3
-- PATH set to C:\Qt\4.4.3\bin
-- Adding C:\MinGW\bin to PATH
-- Adding C:\WINDOWS\System32 to PATH
-- QMAKESPEC set to win32-g++

D:\lote3\test>make release
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `D:/lote3/test'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o release\test.exe release/jose.
o release/main.o -L"c:\Qt\4.4.3\lib" -lopengl32 -lglu32 -lgdi32 -luser32 -lming
w32 -lqtmain -lQtOpenGL4 -lQtGui4 -lQtCore4
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\ mingw32\bin\ld.exe: cannot fin
d -lQtOpenGL4
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\test.exe] Error 1
mingw32-make[1]: Leaving directory `D:/lote3/test'
mingw32-make: *** [release] Error 2

D:\lote3\test>make debug
c:\Qt\4.4.3\bin\qmake.exe -win32 "QT += opengl" -o Makefile test.pro
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `D:/lote3/test'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEED
S_QMAIN -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4
.4.3\include\QtGui" -I"c:\Qt\4.4.3\include\QtGui" -I"c:\Qt\4.4.3\include\QtOpenG
L" -I"c:\Qt\4.4.3\include\QtOpenGL" -I"c:\Qt\4.4.3\include" -I"." -I"c:\Qt\4.4.3
\include\ActiveQt" -I"debug" -I"." -I"c:\Qt\4.4.3\mkspecs\win32-g++" -o debug\jo
se.o jose.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEED
S_QMAIN -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4
.4.3\include\QtGui" -I"c:\Qt\4.4.3\include\QtGui" -I"c:\Qt\4.4.3\include\QtOpenG
L" -I"c:\Qt\4.4.3\include\QtOpenGL" -I"c:\Qt\4.4.3\include" -I"." -I"c:\Qt\4.4.3
\include\ActiveQt" -I"debug" -I"." -I"c:\Qt\4.4.3\mkspecs\win32-g++" -o debug\ma
in.o main.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -mthreads -Wl -Wl,-subsystem,windows -o debug\test.exe debug/jose.o debug/mai
n.o -L"c:\Qt\4.4.3\lib" -lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmaind
-lQtOpenGLd4 -lQtGuid4 -lQtCored4
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\ mingw32\bin\ld.exe: cannot fin
d -lQtOpenGLd4
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\test.exe] Error 1
mingw32-make[1]: Leaving directory `D:/lote3/test'
mingw32-make: *** [debug] Error 2
D:\lote3\test>

If I tried make release version, i got the same mistake.

Well i went to Qt dir, then
>configure
>mingw32-make

j0rt4g4
22nd November 2008, 12:20
If I tried make release version, i got the same mistake.

Well i went to Qt dir, then
>configure
>mingw32-make

Well Doing this the problem is GONE!
In the release and debug mode, both the matter is gone.
Now If I want to compile, I should do it this way:
>qmake -project
>qmake "QT += opengl" test.pro
>make release or
>make debug.

Thank you very much to all.

rexi
28th November 2008, 21:30
Now If I want to compile, I should do it this way:
>qmake -project
>qmake "QT += opengl" test.pro
>make release or
>make debug.

Just by the way: you can add the line
QT += opengl to you test.pro file, like it was said before, so you don't have to add it to the qmake command all the time.

j0rt4g4
2nd December 2008, 03:22
Is there any way I could add the line "QT += opengl" automatically using just "qmake"... :)

lyuts
2nd December 2008, 12:36
Just open your pro file and add this "QT += opengl" to it. After that you just need qmake and make.