Search code examples
c++qtcmakeqmake

Including external libraries to Qt


I am actually new at Qt and would be grateful if someone could explain how to deal with external C++ libraries in theses 3 cases and what is the easiest way to get a library working with Qt (if you could just point me out to some places where I can read about it): - source .h and header .cpp files both available - source .h and DLL - source .h and .a files

I usually use the following procedure: 1- Cmake to generate make files 2- Building using Mingw:

 Cd c:/test
 qmake test.pro
 mingw32-make

3- Including project to Qt:

 INCLUDEPATH += C:/test/build/include
 LIBS += C:\test\build\x64\mingw\lib\file.dll.a \ ...

I usually use Cmake first then qmake to build, but sometimes one is not working or often Qt option is not available in Cmake. I always read carefully the instructions. In general, how an experience programmer would make decisions on how to include a library?


Solution

  • You do not need cmake and qmake together -- One is enough. I mainly work with qmake when i'm in Qt Creator since it is well integrated with the IDE. Generally what you are doing is correct. You include headers under HEADERS +=, sources under SOURCES +=, libraries under LIBS += and the path to the include files under INCLUDEPATH +=.