win32 build stops with linker error

Peter Kümmel syntheticpp at gmx.net
Wed Feb 8 17:54:14 CET 2006


David Faure wrote:
> On Tuesday 07 February 2006 23:05, Peter Kümmel wrote:
>> David Faure wrote:
>>> On Tuesday 07 February 2006 20:29, Christian Ehrlicher wrote:
>>>>> kio.lib(kio.dll) : error LNK2005: "public: class QString & __thiscall QMap<class QString,class QString>::operator[](class QSt
>>>>> ring const &)" (??A?$QMap at VQString@@V1@@@QAEAAVQString@@ABV1@@Z) already defined in khtml_printsettings.obj
>>>>> kio.lib(kio.dll) : error LNK2005: "public: __thiscall QMap<class QString,class QString>::~QMap<class QString,class QString>(v
>>>>> oid)" (??1?$QMap at VQString@@V1@@@QAE at XZ) already defined in khtml_settings.obj
>>> Buuh :(
>>>
>>> IIRC you need "template class QMap<QString,QString>;" in global.cpp
>>> to force a template instantiation there, so that dependent libs don't do it themselves.
>> I've tested it, but this doesn't help, like the error message indicates:
>> there is already a instantiation in kio.
> 
> I just saw something similar in another project here.
> It seems that the explicit instantiation should be in the .h, not in the .cpp,
> and with dlllimport.
> Hmm, that's what you tried first, but try with s/extern template/template class/ ?
> 
> Please don't change the base class, we would have to redefine the whole QMap API...
> 

#ifdef Q_OS_WIN
template class __declspec(dllexport) QMap<QString, QString>;
#endif

Does the job.
Peter


More information about the Kde-buildsystem mailing list