Important: Please read the Qt Code of Conduct -

Manual make install step for static libraries with a .pro file

  • Hello,

    I have static library which is being used in an app. The app is a qt app & I building the library using qt as well. The library has a .pro. I am testing it on ios & android.

    Currently I build the library to a different build directory. The build directory needs to primarily contain the .a & the library header. The header is the interface of the library as it is the convention. I wrote an install rule in my to copy the header to the build directory every-time the library is built. This copy step is working.

    But here is the problem. I had to include a make install step in my project settings to run this extra build step. This something manual. If 10 more developers are using my library then they all have to add this manual step for make install in their project settings. I want to eliminate this manual step so that when a developer imports the library, he just clicks "build" on his qt creator without having to manually add this make install step in his project setting in qt creator. Is it possible to do so ? If yes, then can someone please tell the way to do it ?

    Thanks in advance for any suggestions..

  • In my app I solved that in such a way:

    • I'm keeping compiled static libraries of fftw and ogg in sub-folders of my library source directory
    • .pro file of library that links to them contains the following:
    android {
      INCLUDEPATH += fftw
      contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
        LIBS += -Bstatic -L$$PWD/fftw/armv7/ -lfftw3f -L$$PWD/ogg/armv7/ -loggstatic -Bdynamic
      contains(ANDROID_TARGET_ARCH,x86) {
        LIBS += -Bstatic -L$$PWD/fftw/x86/ -lfftw3f -L$$PWD/ogg/x86/ -loggstatic -Bdynamic

    I hope this example will help You.

  • Lifetime Qt Champion


    Is that static library part of your main Qt Project ? e.g. as a subdir

  • Not so directly. ..
    I put the code just as an example of a possible way how to manage such a cases.
    It could be symbolic links or configured variables of qmake with path to compiled lib file.

  • Lifetime Qt Champion

    Sorry @SeeLook, I meant it as a question for the OP :) But I see your point.

  • My static library is not part of my qt app. It is built separately as a static library using qt. My app only uses the static library for certain functionality but it is only dependent on one header file from the library which is the library's API/interface. And this is the header file I want to provide into the build directory as a part of building the static library.

    Imagine a situation where I tell you as my co-developer that you need to use my library as a part of your app. Qt is great to provide the option that I can add a install step detail by using INSTALL += . I am using this to specify my header to be installed as part of the build but I wish to avoid the manual step so that my co-developer does not need add a install step manually to build my library in his qt creator.

    Is there some config or something I can add to my library's .pro which enforces this make install automatically.. Or is there some completely different way to share my static library's header ? Surely should be a way.. aah.. I am sort of new to this

  • Lifetime Qt Champion

    Since that library is also built with Qt, why not make it part of your current project through a git submodule and use the SUBDIR template to build everything together ?

    That way all your co-worker will use the same version of that static library, there's no need to install it and you can easily point your current project to the needed header.

  • sorry to be late in replying. I am not very sure about the git submodule process. I need to check that out. If this cannot be handled by adding any code to mu library's .pro file, then I would have to look into the git submodule way.
    May be making the "make install" step automatic is not in the purview of a project .pro file..


    Just to clarify readers, Step # 2 in above link is what I wish my co-developers to omit. So that they don't have to do add "make install" step manually. It should come inherent with the library.

  • I figured this out by some more searching around. QMAKE_POST_LINK does something that I was looking for. We can copy a particular file to the build directory or somewhere else by putting it into QMAKE_POST_LINK. Like I added the following line to my .pro file

    QMAKE_POST_LINK = cp "mylibrary_header" "destination_directory"

  • Lifetime Qt Champion

    Again, you are complicating your life for that static library. Integrating it in your current project will avoid your fellows developer to have to build and install it before building the application. Also, that will make their life easier if it's also an actively developed library. With the submodule you can ensure that they are getting a version of this library that is known to work with the application. They won't have to check an external library state + rebuild/install.

    By the way, your current QMAKE_POST_LINK will only work on systems where there's a cp command.

  • Very good points indeed @SGaist. I will take that down. I need to look into how to make it as a git submodule which looks to be much better approach.
    Thanks for your dude. Appreciate

Log in to reply