Results 1 to 8 of 8

Thread: LNK2005 Static library

  1. #1
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Question LNK2005 Static library

    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.
    Last edited by jacek; 6th July 2007 at 19:12. Reason: changed [code] to [quote]

  2. #2
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Wink Qt made static library linker error

    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.
    Last edited by jacek; 6th July 2007 at 21:06. Reason: changed [code] to [quote]

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt made static library linker error

    Please, don't double post and use [code] tags only for code snippets.

  4. #4
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: LNK2005 Static library

    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: LNK2005 Static library

    Quote Originally Posted by TheGrimace View Post
    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.

  6. #6
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: LNK2005 Static library

    Do you mean editing the header files to point at my local Qt before the included lib? Or something else?

    Thank You!

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: LNK2005 Static library

    Quote Originally Posted by TheGrimace View Post
    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.

  8. The following user says thank you to jacek for this useful post:

    TheGrimace (10th July 2007)

  9. #8
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: LNK2005 Static library

    Thank You for your assistance

Similar Threads

  1. Wrap a static QT library inside an XPCOM component ?
    By Paul_Xul in forum Qt Programming
    Replies: 2
    Last Post: 3rd August 2010, 07:16
  2. Replies: 16
    Last Post: 23rd May 2008, 10:12
  3. Building qt program with static library
    By JonathanForQT4 in forum Newbie
    Replies: 2
    Last Post: 22nd June 2007, 23:15
  4. Win32 qmake: building a static library
    By Amanda in forum Qt Programming
    Replies: 5
    Last Post: 8th November 2006, 19:32
  5. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.