External Qt Libraries include a built-in user library

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 +=

(like Eigen) myProject depends on myLib, so I added a dependency with a Qt wizard that 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 runs in, but when I try to compile the project I get errors like

Eigen/Core: No such file or directory

because in the source file of the project I am including some headers from my own libraries which include some headers from external libraries.

The only solution I know to solve this problem is to copy / paste all incoming links and links from myLib.pro to myProject.pro. Is there a better way to do this?
I thought maybe having * .pri for each of the external libraries and include those * .pri in both * .pro. But this is not entirely satisfying.

EDIT: I forgot to mention that myLib is a shared library.

+3


source to share


1 answer


The first thing I would like to check is that you really need these headers in myProject. Think about the myLib API and what is required. If you are passing in Eigen types and matrices, then yes, you will need to add them to your include path and the .pri file can help with that. You might also want to put something like Eigen in the precompiled header. If not, then you should look at reordering your header files to make sure they only do what's needed for that particular header and move as much as possible into your source files. Again, this will help tremendously with your compilation points.



I don't think you are specifying whether it is a myLib

shared or static library. If it is a static library, then yes, you will need to link myProject

to whatever depends on myLib

, but on the other hand, deployment becomes easier and function calls to that library become more efficient. If it is a shared library, you only need to link that library.

0


source







All Articles