PDA

View Full Version : Linking problems with QT4 under Windows



Ancalagon
5th September 2008, 12:17
Hi guys,

Our application runs in both Linux and Windows. The stable release at the moment uses QT3, however one of my colleagues has been porting it from QT3 to QT4 in Linux. He still has some issues to iron out, but has managed to at least get it to compile and start up.

I have to do the same for Windows, of course because we use SVN most of his changes are in effect and work appropriately. I installed QT4.4 on my Windows machine, set up the environment variables manually (I previously had QT3 installed, thus my QT variables were set for QT3), and proceeded to work on the port.

The application takes the form of 2 projects - one produces a library, the other produces an application, which relies on the library produced by the first project. I have succeeded in getting the first project (the library) to compile. The second project does compile, but then fails at linking. I have tried everything I know and simply cannot get linking to succeed. All of the linker errors relate to QT4 - I dont see any that relate to the library. There are a total of 419 linker errors, but most of them are the same, thus I will post a select few. Please let me know if I should post a detailed log elsewhere (it will be very long).

1>GM.lib(moc_GMPointEdit.obj) : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QLineEdit::staticMetaObject" (?staticMetaObject@QLineEdit@@2UQMetaObject@@B)

1>qui.lib(database.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall QDataBrowser::setSqlCursor(class QSqlCursor *,bool)" (?setSqlCursor@QDataBrowser@@UAEXPAVQSqlCursor@@_N @Z)

1>GM.lib(GMCGFXScriptCommand.obj) : error LNK2001: unresolved external symbol "private: static class QTextCodec * QString::codecForCStrings" (?codecForCStrings@QString@@0PAVQTextCodec@@A)

1>main.obj : error LNK2001: unresolved external symbol "private: static class QCoreApplication * QCoreApplication::self" (?self@QCoreApplication@@0PAV1@A)

We use the QT3Support libraries, as some of our classes have not been fully ported yet. I am compiling using Visual Studio 2005 SP1 running on Windows XP SP2. We also make use of various other libraries, including but not limited to Ruby, opengl, some nvidia libraries and mysql. I have tried adding every library in the QT4 libs directory (not that this is a debug build), as well as the QT3 main lib (just in case). They do not solve the unresolved external symbols.

Any help would be appreciated, please let me know if there is any further information I can provide.

Valheru
5th September 2008, 21:12
In the projects options in Visual Studio, have you added the ${QTDIR}\lib directory to the Library settings of the Active Configuration? Or alternatively, set it globally using the global options of Visual Studio? In Visual Studio 9 2008 it is Tools->Options->Projects and Solutions->VC++ Directories, and then select Library Files in the combobox for "Show directories for:"
You should also set up the Include Files while there as well.

Ancalagon
8th September 2008, 14:29
I've already done that - both adding ($QTDIR)\lib and adding the correct folders to the Show Directories for pages for the include files, source code, and libraries.