Results 1 to 9 of 9

Thread: Importing an external libraries(.lib) in QT Project

  1. #1
    Join Date
    Aug 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Importing an external libraries(.lib) in QT Project

    Hi All, I am trying to import some external static libraries in my project. I have .h files, from which I can call functions and their definitions will be in library. Currently I have added .h files in my QT Project and added the static library via the import external library option in project settings. But I am getting error message as "Undefined reference to .... function ....".

    I did some research on it and created a sample QT lib project, Used the .h file of that project in my main project and gave reference to the .a file. It worked.

    Will Libraries created using QT are Importable in a QT project or some other libs such as visual studio libs can also be ported???? Please help as this is very important for my project.

    Thanks


    Added after 10 minutes:


    The same thing is working with the visual studio version of my project.
    Last edited by mohitkap91; 11th September 2015 at 07:45.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,710
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Importing an external libraries(.lib) in QT Project

    Will Libraries created using QT are Importable in a QT project or some other libs such as visual studio libs can also be ported????
    What is the setup you are working with?
    Are you on MSVC or QtCreator?
    If you are on QtCreator are you using the supplied MinGW compiler or the MSVC compiler?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Aug 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Importing an external libraries(.lib) in QT Project

    Quote Originally Posted by high_flyer View Post
    What is the setup you are working with?
    Are you on MSVC or QtCreator?
    If you are on QtCreator are you using the supplied MinGW compiler or the MSVC compiler?
    I am using QTCreator with MinGW compiler.

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,499
    Thanked 277 Times in 272 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Importing an external libraries(.lib) in QT Project

    Perhaps the libraries are built by MSVC and can not be linked with the Mingw modules.

  5. #5
    Join Date
    Aug 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Importing an external libraries(.lib) in QT Project

    If I try to import a lib built using MSVC. Will it be imported on MINGW QTCreator Project?? Is importing MSVC Compiled libraries supported in Qtcreator with MINGw?

  6. #6
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,499
    Thanked 277 Times in 272 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Importing an external libraries(.lib) in QT Project

    This is not the problem of Qt but problem of incompatibility between MSVC and MinGW.
    You must build library from sources with MinGW.
    Last edited by Lesiok; 11th September 2015 at 14:47.

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Importing an external libraries(.lib) in QT Project

    Quote Originally Posted by Lesiok View Post
    This is not the problen of Qt but problem of incompatibility between MSVC and MinGW.
    You must build library from sources with MinGW.
    Or use the MSVS compiler in QtCreator.

    Either way, library and program need to be built by the same compiler.

    Cheers,
    _

  8. #8
    Join Date
    Aug 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Importing an external libraries(.lib) in QT Project

    I installed QTCreator with MSVC. But it was not showing any kit/compiler. So I was not able to import my existing project in MSVC QT.

  9. #9
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,481
    Thanks
    252
    Thanked 711 Times in 701 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Importing an external libraries(.lib) in QT Project

    But it was not showing any kit/compiler.
    Do you have the MSVC compiler installed on your PC? Only the MinGW version of the Qt distribution comes with a compiler; for other versions you have to install it first from elsewhere (like Microsoft).

    If you do have it installed but for some reason Qt Creator did not find it automatically, you can add it manually. On the Qt Creator main menu, execute Tools->Options, click "Build and Run" when the dialog appears, click the "Compilers" tab, then click "Add", and select "Custom". Fill in the information, and be sure you select the correct Qt mkspecs file. (Look in your Qt distrbution, it is under Src/qtbase/mkspecs, one of the win32-msvc... or winnt-x64... entries).

Similar Threads

  1. Replies: 5
    Last Post: 28th February 2015, 20:32
  2. Replies: 2
    Last Post: 10th February 2011, 16:03
  3. Using external libraries
    By Handi in forum Newbie
    Replies: 5
    Last Post: 9th December 2010, 22:51
  4. importing creator project into eclipse
    By piotr.dobrogost in forum Qt Tools
    Replies: 3
    Last Post: 1st June 2009, 00:14
  5. Importing qt project to an eclipse workspace
    By isahin in forum Installation and Deployment
    Replies: 2
    Last Post: 28th January 2008, 18:00

Tags for this Thread

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.