Search code examples
c++qtstatic-librariesqt-creatorstatic-linking

Static linking against non-binary libs


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.


Solution

  • 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