PDA

View Full Version : Qt 4.6 with VS 2008 Express: Linker error when building libraries



scrontch
8th January 2010, 16:38
Hi,
I want to use QT4.6 with VS 2008 Express.
I have roughly followed this guide: http://netindonesia.net/blogs/risman/archive/2009/04/02/qt-4-5-with-visual-studio-2008-vc-express.aspx
I have downloaded and installed Qt libraries 4.6 for Windows (VS 2008, 190 MB, http://qt.nokia.com/downloads/windows-cpp-vs2008)
Then i opened a VS2008 Command Prompt and typed:
configure -platform win32-msvc2008
=>OK
nmake
=>gives the following linker error:
Generating Code...
link /NOLOGO /INCREMENTAL:NO /SUBSYSTEM:CONSOLE /MANIFEST /MANIFESTFILE:
"release\moc.intermediate.manifest" /OUT:..\..\..\bin\moc.exe @C:\DOCUME~1\Max\LOCALS~1\Temp\nm92.tmp
bootstrap.lib(qbytearray.obj) : error LNK2019: unresolved external symbol _uncompress referenced in function "class QByteArray __cdecl qUncompress(unsigned char const *,int)" (?qUncompress@@YA?AVQByteArray@@PBEH@Z)
bootstrap.lib(qbytearray.obj) : error LNK2019: unresolved external symbol _compress2 referenced in function "class QByteArray __cdecl qCompress(unsigned char const *,int,int)" (?qCompress@@YA?AVQByteArray@@PBEHH@Z)
..\..\..\bin\moc.exe : fatal error LNK1120: 2 unresolved externals

Any hints on this?
It seems the functions mentioned are part of zlib?
Do i need to install zlib seperately? From where and how?
Any help will be much appreciated.

squidge
8th January 2010, 18:02
Why not just download the VS2008 version of Qt from Nokia's website?

scrontch
8th January 2010, 20:22
That's what i did.
I tried with both the source- and SDK distribution.
Same issue.

squidge
8th January 2010, 21:40
Ok, I'm confused. Is there a reason you want to reconfigure/rebuild the library when they have already been made for you?

scrontch
9th January 2010, 10:17
Well, isn't this what the official deployment guide for Windows (http://doc.qt.nokia.com/4.6/install-win.html) suggests to do?

squidge
9th January 2010, 11:28
If you want to configure the suite differently for deployment (ie, you want to disable some stuff perhaps) then yes, thats correct. But from your first post you just want the standard version, which has already been done for you.

scrontch
10th January 2010, 10:41
Ok, so i tried using the pre-built libs.
I can compile an example (calculator), but i get linker errors.
I have added the Qt/4.6.0/lib diretcory to the VS2008 Linker lib path, but that doesn't seem to be sufficient.
Any clues?

squidge
10th January 2010, 11:23
Normally you would let the Qt plugin for VS do all the work for you, but since you are using an express edition, you can't do that. So you need to figure out your project dependancies and add them to your project linker section. These will be things like QtCore, QtGUI, and so on.

You can probably use QMake to generate an appropriate project file for you - create the .PRO file either yourself or using QtCreator and then change the platform configuration.

scrontch
10th January 2010, 14:51
Ok, i now have added all Qt lib files to the project and this reduced the number of unresolved symbols.
There are still these though:
1>button.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Button::metaObject(void)const " (?metaObject@Button@@UBEPBUQMetaObject@@XZ)
1>button.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall Button::qt_metacast(char const *)" (?qt_metacast@Button@@UAEPAXPBD@Z)
1>button.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall Button::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Button@@UAEHW4Call@QMetaObject@@HPAP AX@Z)
1>calculator.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Calculator::metaObject(void)const " (?metaObject@Calculator@@UBEPBUQMetaObject@@XZ)
1>calculator.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall Calculator::qt_metacast(char const *)" (?qt_metacast@Calculator@@UAEPAXPBD@Z)
1>calculator.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall Calculator::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Calculator@@UAEHW4Call@QMetaObject@@ HPAPAX@Z)
1>calculator.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const Calculator::staticMetaObject" (?staticMetaObject@Calculator@@2UQMetaObject@@B)
1>calculator.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const Button::staticMetaObject" (?staticMetaObject@Button@@2UQMetaObject@@B)
1>D:\Dev\calculator\Debug\calculator.exe : fatal error LNK1120: 8 unresolved externals

Any ideas?

squidge
10th January 2010, 15:25
Yes, you need to run MOC on the appropriate header files and include the resulting output in your project. The plugin typically associates MOC with the header files for you so it's run whenever the header files are updated. You'll have to do this manually since you don't have the plugin.