PDA

View Full Version : Importing an external libraries(.lib) in QT Project



mohitkap91
11th September 2015, 07:45
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.

high_flyer
11th September 2015, 09:51
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?

mohitkap91
11th September 2015, 11:08
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.

Lesiok
11th September 2015, 12:05
Perhaps the libraries are built by MSVC and can not be linked with the Mingw modules.

mohitkap91
11th September 2015, 12:16
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?

Lesiok
11th September 2015, 12:52
This is not the problem of Qt but problem of incompatibility between MSVC and MinGW.
You must build library from sources with MinGW.

anda_skoa
11th September 2015, 13:23
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,
_

mohitkap91
12th September 2015, 09:04
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.

d_stranz
12th September 2015, 17:00
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).