PDA

View Full Version : QT + eclipse



alberich
24th November 2007, 18:59
Hi!

I'm a newbie on QT and eclipse. I searched a long the forum before ask.

I installed QT, eclipse, qt-eclipse integration, mingw and msys on my windows 64 system.

I created a Qt GUI project, and start coding some class to receive mail throught pop3, all is fine but when i tried to compile/exectute i get a wierd error on console output:


mingw32-make all
mingw32-make -f Makefile.Release all
mingw32-make[1]: Entering directory `C:/Documents and Settings/Eric Draven/workspace/qpop3'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o "release\qpop3.exe" release\main.o release\qpop3.o release\moc_qpop3.o -L"d:\Qt\4.3.2\lib" -lmingw32 -lqtmain -lQtGui4 -lQtCore4
release\qpop3.o:qpop3.cpp:(.text+0x135): undefined reference to `_imp___ZN10QTcpSocketC1EP7QObject'
release\qpop3.o:qpop3.cpp:(.text+0x188): undefined reference to `_imp___ZN15QAbstractSocket13connectToHostERK7QStr ingt6QFlagsIN9QIODevice12OpenModeFlagEE'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\qpop3.exe] Error 1
mingw32-make[1]: Leaving directory `C:/Documents and Settings/Eric Draven/workspace/qpop3'
mingw32-make: *** [release-all] Error 2


Any idea? what is missed?

Thanks!!

Alberich

jacek
24th November 2007, 19:09
You don't link your application with QtNetwork library.

alberich
24th November 2007, 19:41
i got this include on qpop3.h

#include <QTnetwork/QTcpSocket.h>

jacek
24th November 2007, 19:45
Including a header is not enough. You have to tell Eclipse to link QtNetwork module with your application. I don't use Eclipse for Qt development, but you should be able to set which Qt modules you want to use in project's settings.

alberich
24th November 2007, 20:10
which IDE you use?

jacek
24th November 2007, 20:15
which IDE you use?
I use KDevelop.

alberich
24th November 2007, 20:21
and for windows?

jacek
24th November 2007, 20:44
and for windows?
I don't use windows for development.

alberich
25th November 2007, 16:30
Ok, thanks!!

One more question, i linked qtnetwork module but i get the following error on ld:


mingw32-make all
mingw32-make -f Makefile.Release all
mingw32-make[1]: Entering directory `C:/Documents and Settings/Eric Draven/workspace/qpop3'
mingw32-make[1]: Nothing to be done for `all'.
mingw32-make[1]: Leaving directory `C:/Documents and Settings/Eric Draven/workspace/qpop3'
mingw32-make -f Makefile.Debug all
mingw32-make[1]: Entering directory `C:/Documents and Settings/Eric Draven/workspace/qpop3'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o "debug\qpop3.exe" debug\main.o debug\qpop3.o debug\moc_qpop3.o -L"d:\Qt\4.3.2\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtNetworkd4 -lQtCored4
D:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\ mingw32\bin\ld.exe: cannot find -lqtmaind
collect2: ld returned 1 exit status
mingw32-make[1]: Leaving directory `C:/Documents and Settings/Eric Draven/workspace/qpop3'
mingw32-make[1]: *** [debug\qpop3.exe] Error 1
mingw32-make: *** [debug-all] Error 2

Any idea? sorry, for this stupid questions

jacek
25th November 2007, 23:34
D:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\ mingw32\bin\ld.exe: cannot find -lqtmaind
You don't have the debug versions of Qt libraries. There should be a link in Start menu --- "Build Qt libraries in debug mode" or something like that.

satlcard12
27th November 2007, 03:10
I have downloaded and installed the Eclipse 3.3 and the Qt Eclipse Integration for Windows. I need a Qt package and I am asking for recommendations.
Thanks,
Bob

jacek
27th November 2007, 23:39
I need a Qt package and I am asking for recommendations.
What recommendations do you expect from us? Just download the newest version from Trolltech.

alberich
28th November 2007, 00:12
Jacek,

Now i got debug libreries builded. When i build them i get other errors..


mingw32-make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/Eric Draven/workspace/qpop3'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\Qt\4.3.2\include\QtCore" -I"d:\Qt\4.3.2\include\QtCore" -I"d:\Qt\4.3.2\include\QtGui" -I"d:\Qt\4.3.2\include\QtGui" -I"d:\Qt\4.3.2\include" -I"core" -I"gui" -I"network" -I"d:\Qt\4.3.2\include\ActiveQt" -I"debug" -I"." -I"d:\Qt\4.3.2\mkspecs\win32-g++" -o debug\main.o main.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\Qt\4.3.2\include\QtCore" -I"d:\Qt\4.3.2\include\QtCore" -I"d:\Qt\4.3.2\include\QtGui" -I"d:\Qt\4.3.2\include\QtGui" -I"d:\Qt\4.3.2\include" -I"core" -I"gui" -I"network" -I"d:\Qt\4.3.2\include\ActiveQt" -I"debug" -I"." -I"d:\Qt\4.3.2\mkspecs\win32-g++" -o debug\qpop3.o qpop3.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o "debug\qpop3.exe" debug\main.o debug\qpop3.o -L"d:\Qt\4.3.2\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
debug\qpop3.o(.text+0x11f): In function `ZN5QPop3C2EP7QObject':
C:/Documents and Settings/Eric Draven/workspace/qpop3/qpop3.cpp:7: undefined reference to `vtable for QPop3'
debug\qpop3.o(.text+0x145): In function `ZN5QPop3C1EP7QObject':
C:/Documents and Settings/Eric Draven/workspace/qpop3/qpop3.cpp:7: undefined reference to `vtable for QPop3'
debug\qpop3.o(.text+0x1b5): In function `ZN5QPop37connectER7QStringt':
C:/Documents and Settings/Eric Draven/workspace/qpop3/qpop3.cpp:19: undefined reference to `_imp___ZN10QTcpSocketC1EP7QObject'
debug\qpop3.o(.text+0x239):C:/Documents and Settings/Eric Draven/workspace/qpop3/qpop3.cpp:22: undefined reference to `_imp___ZN15QAbstractSocket13connectToHostERK7QStr ingt6QFlagsIN9QIODevice12OpenModeFlagEE'
debug\qpop3.o(.text+0x2d3): In function `ZN5QPop315socketConnectedEv':
C:/Documents and Settings/Eric Draven/workspace/qpop3/qpop3.cpp:37: undefined reference to `QPop3::ConnStateChanged(int)'
debug\qpop3.o(.text+0x2f5): In function `ZN5QPop311socketErrorEN15QAbstractSocket11SocketE rrorE':
C:/Documents and Settings/Eric Draven/workspace/qpop3/qpop3.cpp:49: undefined reference to `QPop3::ConnStateChanged(int)'
debug\qpop3.o(.text+0x310):C:/Documents and Settings/Eric Draven/workspace/qpop3/qpop3.cpp:52: undefined reference to `QPop3::ConnStateChanged(int)'
collect2: ld returned 1 exit status
mingw32-make[1]: Leaving directory `C:/Documents and Settings/Eric Draven/workspace/qpop3'
mingw32-make[1]: *** [debug\qpop3.exe] Error 1
mingw32-make: *** [debug] Error 2


And some other weid error like the ones i got before to link network module to my project.

Thinking that coudl be mingw vesion, i build all ( qt and qt debug ) with the same version but get the same..

Thanks!

jacek
28th November 2007, 00:28
And some other weid error like the ones i got before to link network module to my project.
For some reason you don't link your project with QtNetwork module again. Also make sure that there's Q_OBJECT macro inside QPop3 definition (you will have to run qmake after adding it).

alberich
28th November 2007, 08:10
For some reason you don't link your project with QtNetwork module again. Also make sure that there's Q_OBJECT macro inside QPop3 definition (you will have to run qmake after adding it).

Both are done. I got qtnetwork module, and Q_OBJECT declared inside QPop3. This starts just after i builded debug libraries.

thanks

jacek
28th November 2007, 12:46
Both are done. I got qtnetwork module, and Q_OBJECT declared inside QPop3. This starts just after i builded debug libraries.
If your .pro file is OK (i.e. it contains "QT += network" or equivalent), then you have to force Eclipse to re-run qmake to generate new makefiles.

alberich
29th November 2007, 17:49
I done qmake several times, maybe there's something wrong with my code?



#ifndef __POP3_H_INCLUDED__
#define __POP3_H_INCLUDED__


#include <QtGui/QWidget>
//#include "ui_qpop3.h"

#include <QDialog>
#include <QtCore/QObject.h>
//#include <QTnetwork>
#include <QTnetwork/QTcpSocket.h>

//#include <QTcpSocket>
#include <QtCore/qstring.h>


class QPop3 : public QObject
{
Q_OBJECT
private:

QTcpSocket *socket;
public:
enum ConnectState{
CsHostFound,
CsConnected,
CsClosed,
CsHostNotFound,
CsConnectionRefused
};

// Constructor
explicit QPop3(QObject *parent = 0);
virtual ~QPop3();

int connect(QString &servAdr,quint16 port);


signals:
void ConnStateChanged(int);

private slots:
void socketError(QAbstractSocket::SocketError e);
void socketConnected();

};

#endif



Thanks once again

jacek
29th November 2007, 18:08
I done qmake several times, maybe there's something wrong with my code?
The code looks OK. Do you run "qmake" or "qmake -project"? The former creates makefiles from your .pro file, while the latter generates a new .pro file overwriting the old one (you should run this only once at the beginning of your project).

jacek
29th November 2007, 18:47
I've installed Qt-Eclipse integration on my system. It seems that as long as you have a correct .pro file, "Build Project" or "Build Make Target..." should do the magic. Eclipse is quite unstable on my system and I couldn't make Qt Project Editor to run, so I don't know how it looks like, but you can also open your .proi file in text editor to check if it's OK --- all your .h files should be listed in HEADERS variable, .cpp files in SOURCES and .ui files in FORMS. Also QT should contain at least "core", "gui" and "network".

alberich
29th November 2007, 23:38
I created another project, and put back the files and then all worked.

I supposed, as you said, .pro file was wrong but this is the next level :P

Thanks for all :)