Results 1 to 2 of 2

Thread: How to add static library of visual C++ to QT project

  1. #1
    Join Date
    Apr 2014
    Posts
    9
    Thanks
    2
    Qt products
    Qt4 Qt5 Qt/Embedded PyQt3 PyQt4
    Platforms
    Unix/X11 Windows Android

    Default How to add static library of visual C++ to QT project

    Hello everyone, I have a mylib.lib, I use the Visual C++ 2012 compiler (making a Windows).
    I want add it to my QT project ( build with minGW). if in debug mode it show "error: LNK1104: cannot open file 'MyLibd.lib'" and release mode it cannot link to method in my lib ( undefined reference to method or error: LNK1257: code generation failed)

    - .pro:

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/ -lMyLib
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/ -lMyLibd
    else:unix: LIBS += -L$$PWD/lib/ -lMyLib

    INCLUDEPATH += $$PWD/lib
    DEPENDPATH += $$PWD/lib

    Please help me some hint to fix it.

    Thanks!
    Last edited by pipi; 27th July 2014 at 09:24.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to add static library of visual C++ to QT project

    Qt Code:
    1. error: LNK1104: cannot open file 'MyLibd.lib
    To copy to clipboard, switch view to plain text mode 
    Static libraries built with different compilers will be incompatible, there is no way to link to a static C++ library compiled with vc++ to code compiled with gcc. This limitation does not affect plain "C" libraries - you can compile a static C library with gcc and use (link to) it in visual studio.
    Solution is to add the library sources to your Qt/gcc project and rebuild everything with the same compiler (of course only if you don't use anything specific to vc++ in this library).

Similar Threads

  1. Replies: 3
    Last Post: 20th December 2012, 12:48
  2. Visual Studio Project Name
    By fruzzo in forum Qt Programming
    Replies: 2
    Last Post: 2nd April 2012, 10:32
  3. Replies: 2
    Last Post: 19th February 2011, 11:26
  4. Replies: 4
    Last Post: 18th December 2009, 18:55
  5. how to use static library in qt4?
    By hashb in forum Qt Programming
    Replies: 9
    Last Post: 28th October 2009, 12:46

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.