I use qmake to build a project. The project contains several static libs and a executable. The executable links to the static libraries and therefore has the path of the library added to the INCLUDEPATH variable.
When I change something in the header files of the executable everything is rebuild as expected. When changing a header file of the library it just rebuilds the library and relinks the executable. Source files in the executable that include header files from the library are not rebuild correctly.
After investigating the problem I saw that the generated makefiles do not track the dependencies correctly. Only files included with a relative path are tracked. Any header included via INCLUDEPATH is not tracked. Is there something I can do to make it work as expected?
You should add the paths you added to INCLUDEPATH to DEPENDPATH as well.
Related
I am developing a C++ app with Qt that depends on the GNU Scientific Library (GSL).
So far, I have linked GSL in the .pro file using LIBS += /path/to/my/GSL/location -l<name_of_the_library> and it works, but it depends on where I installed GSL.
I'd like the .pro file not to depend on the user-specific GSL path, and possibly include the precompiled libraries (for different OSes) in the project folder.
Is this possible?
In this case it works on all platforms. You have to separate the directory from the library name
LIBS += -L/path/to -lpsapi
In this case You store your lib files in the project directory.
LIBS += -L"$$_PRO_FILE_PWD_/3rdparty/libs/" -lpsapi
look at this for more: https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html
I downloaded pre-built win32 poppler binaries from this page. But saw only the bin folder and not include/bin folders. I need a include folder (which must contains my poppler-qt5 folder) to put in my .pro file (i'm using qt5 to test).
My .pro:
INCLUDEPATH += "C:\\test_folder\\poppler-0.24.5-win32\\include\\poppler-qt5"
LIBS += -L/"C:\\test_folder\\poppler-0.24.5-win32\\lib"
My questions is:
Where should I put the bin folder, is the include folder provided by the release? Or should I put the include folder from this release inside poppler-win32 folder?
I want to make use of two libraries QCustomPlot and Eigen with Qt Creator on OS X.
Both do not need to be installed and work fine if I just put them into my project folder and add them to the project. They do not have to be installed, "you can use the header files right away".
However I want them to be more independet than that, located outside the project to be used by other projects as well and I don't want their headers and source files to appear with my project files. But I do not know how to link them statically.
INCLUDEPATH += /../../Eigen/Eigen \ and
Add Library... -> External Library
apperently does not work, second one because their is no library file to open.
I have no experience with libraries and tend to find this topic highly complicated.
For the template only include library INCLUDEPATH should be sufficient as noted in comments. Generally, you can do it by manually modifying YourProject.pro file like:
LIBS += -L$$PWD/path_relative_to_pro_file/lib -lmylibfile1 -lmyflibfile2
INCLUDEPATH += $$PWD/path_relative_to_pro_file/lib/include
And your library file names end with .lib.
In case if you want your project to be recompiled because of external library change:
DEPENDPATH += $$PWD/path_relative_to_pro_file/lib
DEPENDPATH += $$PWD/path_relative_to_pro_file/lib/include
I have a Qt project that looks like this:
myLib/
myLib.pro
(some *.h, *.cpp)
myProject/
myProject.pro
(some *.h, *.cpp)
myLib.pro includes some external libraries using INCLUDEPATH += and LIBS += (for example Eigen)
myProject depends on myLib, so I added the dependency with the Qt wizard which added to myProject.pro something like:
unix|win32: LIBS += -L$$OUT_PWD/../myLib/ -lmyLib
INCLUDEPATH += $$PWD/../myLib
DEPENDPATH += $$PWD/../myLib
The problem is when I compile the library it works, but when I try to compile the project I get errors like
Eigen/Core: No such file or directory
because in my project's source file I include some headers from my own libraries which include some headers from an external libraries.
The only solution I know to solve this is to copy/paste all the includes and links from myLib.pro to myProject.pro also. Is there a better way to do this?
I was thinking maybe having a *.pri for each of the external libraries and include these *.pri in both *.pro. But this is not completely satisfying.
EDIT:
I forgot to mention myLib is a shared library
The first thing I would check is that you actually need these headers in myProject. Think carefully about the API of myLib and what that requires. If you are passing in Eigen types and matrices then yes you will need to add them to your include path and a .pri file might help with this. You may also want to consider putting something like Eigen in a pre-compiled header. If not then you should look at rearranging your header files to make sure they are only pulling in what is needed for that particular header and move as many includes as possible into your source files. Again this will dramatically help with your compile times.
I don't think you mention whether myLib is a shared or static library. If it is a static library then yes you will need to link myProject to everything that myLib depends upon but the flip side is that deployment becomes easier and function calls into that library become more efficient. If it is a shared library then you only need to link to that library.
So my problem is next: I need to connect to my project Boost, FFMpeg, OpenCV and OpenAL. I have putted all .lib files for tham into some C://libs/ and headers and additional source into C://headers/ and C://src/ so I have this 3 folders I will need to cnnect to my project... I am so very new to qt and I am starting to read books on it and stuff but by now I have not found info on connectimg additional libs and source folders for projects...
And If you happen to know how to do what I am asking fore I have one more question - I have a folder called C://dlls/ with dlls I need to be placed into folder with .exe file how to add such to .pro file?
I found something like
unix:LIBS += -L/usr/lib -lboost_regex
win32:LIBS +=C:/Qt/2010.02.1/qt/lib/libboost_regex.lib
but here they connect a file - not folder and only a lib - no headers=(
For the header files, add the path to the folders to the INCLUDEPATH variable:
INCLUDEPATH += C:/headers/
For the libraries, add them to your LIBs as in your example. You may need to do this one-by-one, or you could set something up for qmake to process the directory and add the given files.
LIBS +=C:/Qt/2010.02.1/qt/lib/libboost_regex.lib
For the source files, if the libraries are properly compiled, you shouldn't need to reference them in your code project. If you do, add them to the sources list like your other code to be compiled.
For the dlls, that is more of an installation problem than a compile problem. However, you might be able to give qmake a post-link command to run to copy the dlls into the same folder as the target executable.