Important: Please read the Qt Code of Conduct -

Including multiple .pri files similar to Makefiles

  • As I stated in a previous post, I'm not a genius with Qt's pro file. I was hoping that it worked similar to Makefile includes. For example, I'm creating a directories.pri that defines the directory locations, in the form of My_Directory = /home/usr/buildarea/ of some libraries. From there I have a top level defaults.pri that includes directories.pri and then uses the $${My_Directory} to resolve paths for libs and such. Both directories.pri and defaults.pri live on the same directory level. In a sub directory I have a file including defaults.pri, but none of the directories defined in directories.pri are resolving. In fact doing a !include(directories.pri) resolves as true. Why is my sub directory's .pro unable to resolve the other pri file. Is it searching at it's own directory level instead of where defaults.pri includes it? Can you include only one .pri file?

  • Lifetime Qt Champion


    It's a bit hard for me to understand your setup.

    Can you upload a concrete example of what you are doing?


  • @aha_1980 As I was typing out the entire structure i figured out my issue ( an aha moment indeed). I was trying to use a directory defined in directories.pri by using $(Directory) instead of $${Directory}. I'll still show my directory so others will learn as well.

    Application Directory Structure

    • Application

    • itemdirectories.pri
    • defaults.pri
    • application
       *.hpp - headers
       *.cpp – sources

    MY_DIR = $(TOPDIR)/library #TOPDIR is set at the environment

    LIBS += -L$${MY_DIR)/lib \ #My mistake here was I had $(MY_DIR) instead of $${MY_DIR}
    INCLUDEPATH += $${MY_DIR}/inc \

  • Lifetime Qt Champion


    I like people getting aha moments when reading my posts :)

    Glad you figured it out and thanks for sharing.


Log in to reply