PDA

View Full Version : LNK2005 Static library



TheGrimace
6th July 2007, 18:30
I am trying to include a 3rd party Qt made static library in my Qt project thread. Whenever I instantiate an instance of the class, however, I get the following linker error:


Error 1 error LNK2005: "public: __thiscall QString::QString(char const *)" (??0QString@@QAE@PBD@Z) already defined in QtCored4.lib(QtCored4.dll) c:\Source\QT4_Core\PMD Monitor\PmdClientApi.lib 1


And about a hundred more just like that. All having to do with QString.

TheGrimace
6th July 2007, 20:56
I am trying to include a 3rd party Qt made static library in my Qt project thread. Whenever I instantiate an instance of the class, however, I get the following linker error:


Error 1 error LNK2005: "public: __thiscall QString::QString(char const *)" (??0QString@@QAE@PBD@Z) already defined in QtCored4.lib(QtCored4.dll) c:\Source\QT4_Core\PMD Monitor\PmdClientApi.lib 1

And about a hundred more just like that. All having to do with QString.

jacek
6th July 2007, 21:06
Please, don't double post and use [code] tags only for code snippets.

TheGrimace
6th July 2007, 21:10
How can I delete an old post when I put it on the wrong forum? If I knew how, I wouldn't have double-posted.

jacek
6th July 2007, 21:48
How can I delete an old post when I put it on the wrong forum? If I knew how, I wouldn't have double-posted.
You can't delete posts. If your post was in a wrong section, I would move it.

The problem is that you have two Qt implementations, the one inside that static library and the one you link your application with. Both of them define the same symbols and linker doesn't know which one to choose. If you link that 3rd party library with Qt dynamically (with the same version you use), the problem should go away. But I don't know if there is some solution that would allow you to leave that library untouched.

TheGrimace
9th July 2007, 14:52
Do you mean editing the header files to point at my local Qt before the included lib? Or something else?

Thank You!

jacek
9th July 2007, 16:07
Do you mean editing the header files to point at my local Qt before the included lib? Or something else?
No, you have to recompile that 3rd party library.

TheGrimace
10th July 2007, 15:43
Thank You for your assistance