Reputation: 1681
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?
Upvotes: 3
Views: 8709
Reputation: 7079
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 +=
.
Upvotes: 4
Reputation: 2129
Instead of manually adding the external library to the .pro file u can do one thing.
Right click on your main project, then select "add library" option then it will ask for
1. External library
2. Internal Library
3. System Library
then select External library , and rest all thing is done by the Qt Creator i.e it will automatically add the path to the .pro file and link the library to your project.
Upvotes: 4