views:

637

answers:

3

Today I dediced to make static linking in Qt. I used Qt4 with Visual Studio and static C runtime article. The 3rd step took quite a long time. When it was finished I opened my project in VS 2008, made Build->Clean Solution and try to Release. Unfortunately I got link errors:

warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

error LNK2019: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A) referenced in function "public: __thiscall QString::QString(void)" (??0QString@@QAE@XZ)

error LNK2019: unresolved external symbol "private: static struct QByteArray::Data QByteArray::shared_null" (?shared_null@QByteArray@@0UData@1@A) referenced in function "public: __thiscall QByteArray::QByteArray(void)" (??0QByteArray@@QAE@XZ)

error LNK2001: unresolved external symbol "private: static struct QByteArray::Data QByteArray::shared_null" (?shared_null@QByteArray@@0UData@1@A)

error LNK2001: unresolved external symbol "public: static struct QMetaObject const QDialog::staticMetaObject" (?staticMetaObject@QDialog@@2UQMetaObject@@B)

error LNK2001: unresolved external symbol "public: static struct QMetaObject const QDialog::staticMetaObject" (?staticMetaObject@QDialog@@2UQMetaObject@@B)

error LNK2001: unresolved external symbol "public: static struct QMetaObject const QDialog::staticMetaObject" (?staticMetaObject@QDialog@@2UQMetaObject@@B)

error LNK2019: unresolved external symbol "public: static enum QSysInfo::WinVersion const QSysInfo::WindowsVersion" (?WindowsVersion@QSysInfo@@2W4WinVersion@1@B) referenced in function _WinMain@16

What i did wrong? Help to fix this pls.

A: 

Make sure that you rerun qmake on your own Qt project after recompiling Qt. The build flags need to be updated in the project as well.

ak
A: 

Those instructions are for VS2005. That warning you got is against the lib multithreaded static C runtime library. Personally, I would not have changed those values from -MD to -MT and -MDd to MTd in the qmake.conf. I would have left them as they were. Anyway, if you are using a Visual Studio solution, you have to go to your C++ compiler options and change those lib settings to MT and MTd.

Michael
Tried to set -MtD in Project Settings and rebuild. Errors remained. Also tried to generate *.pro file and build. Got 270+ link errors.
ChruS
A: 

Can you post the command line that you used for configuring and building Qt? Did you get any errors or major warnings while building Qt? I recommend not changing anything in the .conf file unless you are certain of what you are doing. It really shouldn't be needed for what you are doing. I'd also suggest downloading a fresh copy of the Windows source distribution, or doing a fresh unpack if you still have the archive, just to be certain that you don't have any leftover files from the previous build that might not have been properly removed. Then, do your configure and nmake.

wrosecrans