PDA

View Full Version : Linking QT 3.3 in windows



siddharth_univ
17th February 2007, 09:11
Hey guys,

I'm a noobie in using QT. My office uses qt 3.3.4 and i installed it on my home system. I was reading thru the book examples and was trying out the QDialog class code. I use visual Studio 2003. After i use qmake to generate the .pro and the Makefile, i dont know how to compile the program in visual studio using the makefile.

I tried building without the makefile, but i get linker errors and the book says that there would be linker error as the code has to do something with moc.exe and all. Could anyone help me in this regard?

THanx

Siddharth

sunil.thaha
17th February 2007, 09:56
you need to generate a Visual studio solunion file from the pro file. Run



qmake -t vcapp

siddharth_univ
18th February 2007, 06:47
I am not getting the .vcproj file after I execute that command. Also i tried the -t and -o parameters , but in vain. Can i use nmake.exe to use the makefile?

siddharth

jacek
18th February 2007, 13:00
I am not getting the .vcproj file after I execute that command.
In what directory did you run it? qmake will look for your .pro file in the current directory.


Can i use nmake.exe to use the makefile?
Yes, that's why qmake generates it.

siddharth_univ
19th February 2007, 08:33
well i set the path to the bin directory containg the qmake.exe and i went to the directory containing .pro and makefile and used the qmake in that directory which has the .cpp, .h , .pro and make file. I am actually tryign to learn from the qt 3 gui programming book and in the second chapter it explains on how to create a dialog box with out using the qt designer. When i build, i get linker errors and the book says taht i have to qmake to solve the linker problem.

So can anyone help me please?

jacek
19th February 2007, 18:32
well i set the path to the bin directory containg the qmake.exe and i went to the directory containing .pro and makefile and used the qmake in that directory which has the .cpp, .h , .pro and make file.
Try doing it from the "Qt Command Prompt" (there should be a link in Start menu that opens it) --- it should set up your evironment.


i get linker errors
Could you post first few error messages?

siddharth_univ
24th February 2007, 07:34
QT_Dialog.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall FindDialog::qt_property(int,int,class QVariant *)" (?qt_property@FindDialog@@UAE_NHHPAVQVariant@@@Z)

QT_Dialog.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall FindDialog::qt_emit(int,struct QUObject *)" (?qt_emit@FindDialog@@UAE_NHPAUQUObject@@@Z)

QT_Dialog.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall FindDialog::qt_invoke(int,struct QUObject *)" (?qt_invoke@FindDialog@@UAE_NHPAUQUObject@@@Z)

QT_Dialog.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall FindDialog::qt_cast(char const *)" (?qt_cast@FindDialog@@UAEPAXPBD@Z)

QT_Dialog.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall FindDialog::className(void)const " (?className@FindDialog@@UBEPBDXZ)

QT_Dialog.obj : error LNK2001: unresolved external symbol "public: static class QString __cdecl FindDialog::tr(char const *,char const *)" (?tr@FindDialog@@$$FSA?AVQString@@PBD0@Z)

QT_Dialog.obj : error LNK2001: unresolved external symbol "public: static class QMetaObject * __cdecl FindDialog::staticMetaObject(void)" (?staticMetaObject@FindDialog@@$$FSAPAVQMetaObject @@XZ)

QT_Dialog.obj : error LNK2001: unresolved external symbol "protected: void __thiscall FindDialog::FindNext(class QString const &,bool)" (?FindNext@FindDialog@@$$FIAEXABVQString@@_N@Z)

QT_Dialog.obj : error LNK2001: unresolved external symbol "protected: void __thiscall FindDialog::FindPrev(class QString const &,bool)" (?FindPrev@FindDialog@@$$FIAEXABVQString@@_N@Z)
C:\QtProgs\QT_Dialog\Debug\QT_Dialog.exe : fatal error LNK1120: 9 unresolved externals


these arethe linker errors i get..can anyone help me out here?

jacek
24th February 2007, 20:31
Add #include "QT_Dialog.moc" at the end of QT_Dialog.cpp, then re-run qmake and make.

siddharth_univ
25th February 2007, 02:44
I think i'm missing something here. I read that i have to use moc.exe to generate the obj files..I use visual studio 2003..and can you tell me how to use the moc?

thanx

siddharth

jacek
25th February 2007, 14:46
I use visual studio 2003..and can you tell me how to use the moc?
I don't use VS, so sunil.thaha will have to answer that.

sunil.thaha
26th February 2007, 07:38
Neither do I ;).

I used to develop Qt applications using VS 6 but not any more :D. IIRC I after hand coding / using the qmake -project for creating the Qt .pro file. I ran the qmake -t vcapp in the same directory where pro file is present, and that would give me a .dsp file ( VS 6.0 ).

Inorder to run the moc on a header file I used the VS integration Toolbar.