PDA

View Full Version : Linking problems with multiply defined symbols



JimBrown
1st March 2007, 22:07
Hi,

I'm using Qt 4.2.2 on an XP box and using nmake (C:\Program Files\Microsoft Visual Studio 8\VC\bin\nmake.exe).

I'm working on a legacy app that used STL strings and I'm getting multiply defined symbols linker errors because std::basic_string is defined in qtmain.lib and in msvcprt.lib.

Has anyone else come across this problem?

Thank you for your time.

wysota
1st March 2007, 22:37
Can we see the errors?

JimBrown
2nd March 2007, 13:11
Can we see the errors?

Sure!

qtmain.lib(qtmain_win.obj) : error LNK2005: "class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char
,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_str
ing<char,struct std::char_traits<char>,class std::allocator<char> > const &,clas
s std::basic_string<char,struct std::char_traits<char>,class std::allocator<char
> > const &)" (??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std @@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$al locator@D@2@@0@ABV10@0@Z) already defined in msvcprt.lib(MSVCP80.dll)

qtmain.lib(qtmain_win.obj) : error LNK2005: "class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char
,struct std::char_traits<char>,class std::allocator<char> >(char const *,class s
td::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
const &)" (??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std @@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$al locator@D@2@@0@PBDABV10@@Z) already defined in msvcprt.lib(MSVCP80.dll)

qtmain.lib(qtmain_win.obj) : error LNK2005: "class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char
,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_str
ing<char,struct std::char_traits<char>,class std::allocator<char> > const &,char
const *)" (??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std @@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$al locator@D@2@@0@ABV10@PBD@Z) already defined in msvcprt.lib(MSVCP80.dll)

jacek
2nd March 2007, 15:58
Have you built Qt 4.2.2 yourself?

JimBrown
2nd March 2007, 16:13
Have you built Qt 4.2.2 yourself?

No. I am using it right out of the box.

jacek
2nd March 2007, 16:48
No. I am using it right out of the box.
That might be the problem. Since you use the commercial version, you could ask the Trolltech support whether they know any better solution, but I would simply try to recompile Qt to make sure that it's compatible with your toolchain.