Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Subproject builds by itself, but can't find includes when entire project is built.



  • I don't understand how subproject include paths work. I have a subproject that builds if I right-click on it and select "Build Subproject." When I build the entire project, the subproject in question can't find any of it's own included headers. This is the .pro file for the subproject:

    # Created by and for Qt Creator This file was created for editing the project sources only.
    # You may attempt to use it for building too, by modifying this file here.
    
    QT       -= core gui
    
    TARGET = Gamma
    TEMPLATE = lib
    
    DEFINES += GAMMA_LIBRARY
    
    HEADERS = \
       $$PWD/external/include/portaudio.h \
       $$PWD/external/include/sndfile.h \
       $$PWD/Gamma/Access.h \
       $$PWD/Gamma/Allocator.h \
       $$PWD/Gamma/Analysis.h \
       $$PWD/Gamma/arr.h \
       $$PWD/Gamma/AudioIO.h \
       $$PWD/Gamma/Config.h \
       $$PWD/Gamma/Constants.h \
       $$PWD/Gamma/Containers.h \
       $$PWD/Gamma/Conversion.h \
       $$PWD/Gamma/Delay.h \
       $$PWD/Gamma/DFT.h \
       $$PWD/Gamma/Domain.h \
       $$PWD/Gamma/Effects.h \
       $$PWD/Gamma/Envelope.h \
       $$PWD/Gamma/FFT.h \
       $$PWD/Gamma/Filter.h \
       $$PWD/Gamma/FormantData.h \
       $$PWD/Gamma/Gamma.h \
       $$PWD/Gamma/gen.h \
       $$PWD/Gamma/HRFilter.h \
       $$PWD/Gamma/ipl.h \
       $$PWD/Gamma/mem.h \
       $$PWD/Gamma/Node.h \
       $$PWD/Gamma/Noise.h \
       $$PWD/Gamma/Oscillator.h \
       $$PWD/Gamma/Print.h \
       $$PWD/Gamma/pstdint.h \
       $$PWD/Gamma/Recorder.h \
       $$PWD/Gamma/rnd.h \
       $$PWD/Gamma/SamplePlayer.h \
       $$PWD/Gamma/Scheduler.h \
       $$PWD/Gamma/scl.h \
       $$PWD/Gamma/SoundFile.h \
       $$PWD/Gamma/Spatial.h \
       $$PWD/Gamma/Strategy.h \
       $$PWD/Gamma/Sync.h \
       $$PWD/Gamma/tbl.h \
       $$PWD/Gamma/Thread.h \
       $$PWD/Gamma/Timer.h \
       $$PWD/Gamma/TransferFunc.h \
       $$PWD/Gamma/Types.h \
       $$PWD/Gamma/UnitMaps.h \
       $$PWD/src/fftpack++.h \
       $$PWD/gamma.h
    
    SOURCES = \
       $$PWD/src/arr.cpp \
       $$PWD/src/AudioIO.cpp \
       $$PWD/src/Conversion.cpp \
       $$PWD/src/DFT.cpp \
       $$PWD/src/Domain.cpp \
       $$PWD/src/FFT_fftpack.cpp \
       $$PWD/src/fftpack++1.cpp \
       $$PWD/src/fftpack++2.cpp \
       $$PWD/src/Print.cpp \
       $$PWD/src/Recorder.cpp \
       $$PWD/src/Scheduler.cpp \
       $$PWD/src/scl.cpp \
       $$PWD/src/SoundFile.cpp \
       $$PWD/src/Timer.cpp
    
    INCLUDEPATH = \
        $$PWD/. \
        $$PWD/external/include \
        $$PWD/Gamma \
        $$PWD/src
    
    DEPENDPATH = \
        $$PWD/. \
        $$PWD/external/include \
        $$PWD/Gamma \
        $$PWD/src
    
    #LibSndFile
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/external/lib_win64/ -llibsndfile-1
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/external/lib_win64/ -llibsndfile-1d
    else:unix: LIBS += -L$$PWD/external/lib_win64/ -llibsndfile-1
    
    INCLUDEPATH += $$PWD/external/lib_win64
    DEPENDPATH += $$PWD/external/lib_win64
    
    #PortAudio
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/external/lib_win64/ -lportaudio_x64
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/external/lib_win64/ -lportaudio_x64d
    else:unix: LIBS += -L$$PWD/external/lib_win64/ -lportaudio_x64
    
    INCLUDEPATH += $$PWD/external/lib_win64
    DEPENDPATH += $$PWD/external/lib_win64
    
    

    And this is the .pro file for the top-level subdir project that contains it:

    TEMPLATE = subdirs
    SUBDIRS = App Gamma
    
    App .depends = Gamma
    
    win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/gamma/release/ -lGamma
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/gamma/debug/ -lGamma
    else:unix: LIBS += -L$$OUT_PWD/gamma/ -lGamma
    
    INCLUDEPATH += $$PWD/Gamma
    DEPENDPATH += $$PWD/Gamma
    

    I can alter an example include statement from e.g.

    "#include "Gamma/gen.h""
    

    to

    "#include "../Gamma/gen.h""
    

    And that works. If I print $$PWD from the top-level during QMake I get the project folder, so I though adding $$PWD/Gamma to the INCLUDEPATH would give me what I need.

    I've also tried adding the following to the INCLUDEPATH and DEPENDPATH in the top-level .pro file:
    .
    ..
    Gamma
    ./Gamma
    ./Gamma/Gamma
    ../Gamma
    ../Gamma/Gamma
    $$PWD/Gamma/Gamma

    I clearly misapprehend something about this process, what is it?


  • Lifetime Qt Champion

    @Yosemite your App needs an own .pro file.

    The toplevel .pro file only contains the subdirs and depends, nothing else.

    You can factor out common includes into a .pri file and include in all .pro, though.



  • @aha_1980 Thanks for the reply. App does have a .pro file, I just didn't include it because the errors were with the Gamma project. This is it:

    
    QT += qml quick widgets printsupport
    RESOURCES += qml.qrc \
        styles.qrc
    TEMPLATE = app
    CONFIG += c++17
    
    HEADERS = \
       $$PWD/external/exprtk/exprtk.hpp \
       $$PWD/external/qcustomplot/qcustomplot.h \
       $$PWD/amod.h \
       $$PWD/audifier.h \
       $$PWD/callback.h \
       $$PWD/commands.h \
       $$PWD/constants.h \
    #   $$PWD/dataprocessor.h \
       $$PWD/dataset.h \
       $$PWD/enums.h \
       $$PWD/envelope.h \
       $$PWD/equalizer.h \
       $$PWD/filereader.h \
       $$PWD/fmod.h \
       $$PWD/frame.h \
       $$PWD/granulator.h \
       $$PWD/mainwindow.h \
       $$PWD/mapevaluator.h \
       $$PWD/noise.h \
       $$PWD/oscillator.h \
       $$PWD/panner.h \
       $$PWD/parameter.h \
       $$PWD/parameterfloat.h \
       $$PWD/parameterfloatinterface.h \
       $$PWD/parameterindex.h \
       $$PWD/parameterindexinterface.h \
       $$PWD/playhead.h \
       $$PWD/ringbuffer.h \
       $$PWD/style.h \
       $$PWD/synthitem.h \
       $$PWD/track.h \
       $$PWD/trackheader.h \
       $$PWD/trackname.h \
       $$PWD/trackplotter.h \
       $$PWD/trackview.h \
       $$PWD/transport.h \
       $$PWD/transportwidget.h \
       $$PWD/userdata.h \
       $$PWD/utility.h \
       $$PWD/volume.h
    
    SOURCES = \
       $$PWD/external/qcustomplot/qcustomplot.cpp \
       $$PWD/images/alpha.png \
       $$PWD/images/AM.png \
       $$PWD/images/AUD.png \
       $$PWD/images/down-arrow.svg \
       $$PWD/images/ENV.png \
       $$PWD/images/EQ.png \
       $$PWD/images/FM.png \
       $$PWD/images/interpolate-off.svg \
       $$PWD/images/interpolate-on.svg \
       $$PWD/images/logo.png \
       $$PWD/images/logo.svg \
       $$PWD/images/loop-off.svg \
       $$PWD/images/loop-on.svg \
       $$PWD/images/MOD.png \
       $$PWD/images/NSE.png \
       $$PWD/images/OSC.png \
       $$PWD/images/OUT.png \
       $$PWD/images/PAN.png \
       $$PWD/images/pause.svg \
       $$PWD/images/play.svg \
       $$PWD/images/up-arrow.svg \
       $$PWD/images/VOL.png \
       $$PWD/AM.qml \
       $$PWD/amod.cpp \
       $$PWD/AUD.qml \
       $$PWD/audifier.cpp \
    #   $$PWD/dataprocessor.cpp \
       $$PWD/dataset.cpp \
       $$PWD/deployment.pri \
       $$PWD/Editor.qml \
       $$PWD/EditorDoubleSpinBox.qml \
       $$PWD/EditorFixed.qml \
       $$PWD/EditorFloatParameter.qml \
       $$PWD/EditorLabel.qml \
       $$PWD/EditorLayout.qml \
       $$PWD/EditorMapper.qml \
       $$PWD/EditorMenu.qml \
       $$PWD/EditorParameterHeader.qml \
       $$PWD/EditorScaler.qml \
       $$PWD/EditorTitle.qml \
       $$PWD/ENV.qml \
       $$PWD/envelope.cpp \
       $$PWD/EQ.qml \
       $$PWD/equalizer.cpp \
       $$PWD/filereader.cpp \
       $$PWD/FM.qml \
       $$PWD/fmod.cpp \
       $$PWD/granulator.cpp \
       $$PWD/ItemCreation.js \
       $$PWD/main.cpp \
       $$PWD/main.qml \
       $$PWD/mainwindow.cpp \
       $$PWD/noise.cpp \
       $$PWD/NSE.qml \
       $$PWD/OSC.qml \
       $$PWD/oscillator.cpp \
       $$PWD/OUT.qml \
       $$PWD/Palette.qml \
       $$PWD/PaletteItem.qml \
       $$PWD/PAN.qml \
       $$PWD/panner.cpp \
       $$PWD/parameter.cpp \
       $$PWD/parameterfloat.cpp \
       $$PWD/parameterfloatinterface.cpp \
       $$PWD/parameterindex.cpp \
       $$PWD/parameterindexinterface.cpp \
       $$PWD/PatchManager.qml \
       $$PWD/playhead.cpp \
       $$PWD/qml.qrc \
       $$PWD/README.md \
       $$PWD/SessionCode.js \
       $$PWD/Style.js \
       $$PWD/styles.qrc \
       $$PWD/styles.qss \
       $$PWD/synthitem.cpp \
       $$PWD/SynthItem.qml \
       $$PWD/track.cpp \
       $$PWD/trackheader.cpp \
       $$PWD/trackname.cpp \
       $$PWD/trackplotter.cpp \
       $$PWD/trackview.cpp \
       $$PWD/transport.cpp \
       $$PWD/transportwidget.cpp \
       $$PWD/utility.cpp \
       $$PWD/Utils.js \
       $$PWD/VOL.qml \
       $$PWD/volume.cpp
    
    INCLUDEPATH = \
        $$PWD/. \
        $$PWD/external/qcustomplot
    
    

    Apologies though, I'm not sure what you're asking me to try otherwise. Are you saying that my top-level .pro file has something it shouldn't, or that it is missing something?


  • Lifetime Qt Champion

    @Yosemite yeah, remove everything except

    TEMPLATE = subdirs
    SUBDIRS = App Gamma
    App .depends = Gamma

    from the top level pro file and move it into a .pri file.



  • @aha_1980

    Gotcha. Here is the new top-level .pro file:

    TEMPLATE = subdirs
    SUBDIRS = App Gamma
    
    App.depends = Gamma
    

    And the common.pri:

    Gamma.subdir = Gamma
    App.subdir = App
    
    INCLUDEPATH += $$PWD/Gamma
    DEPENDPATH += $$PWD/Gamma
    

    I tried including common.pri in the Gamma .pro file thusly:

    !include(common.pri) {
        error("common.pri not found")
    }
    

    But there was no change. The Gamma library still can't find the Gamma include files. Tried including in the top-level .pro just in case, with the same result.


  • Lifetime Qt Champion

    @Yosemite

    Gamma.subdir = Gamma App.subdir = App

    remove that from the .pri file.

    Then do a full rebuild with running qmake

    Have a look at the compiler output to see the includepaths passes to the compiler

    Your on a good way, you just need to fine-tune a bit!



  • I did get there eventually, I really appreciate the help @aha_1980 .

    I'll try and state what was done clearly, to see if I understand it and to complete the thread. I included common.pri in the Gamma. pro file. I wrote the include path relative to the entire project folder, after printing $$PWD and seeing it was the top-level project folder.

    There were other errors in the .pro files, especially a bunch of extra src files that were accidentally added while importing the subprojects, so here are the results.

    Top-level .pro file:

    TEMPLATE = subdirs
    SUBDIRS = App Gamma
    
    App.depends = Gamma
    
    

    common.pri file:

    INCLUDEPATH += $$PWD/Gamma
    DEPENDPATH += $$PWD/Gamma
    

    Gamma .pro file:

    # Created by and for Qt Creator This file was created for editing the project sources only.
    # You may attempt to use it for building too, by modifying this file here.
    
    QT       -= core gui
    
    TARGET = Gamma
    
    TEMPLATE = lib
    
    CONFIG+= staticlib
    
    DEFINES += GAMMA_LIBRARY
    
    HEADERS = \
       $$PWD/external/include/portaudio.h \
       $$PWD/external/include/sndfile.h \
       $$PWD/Gamma/Access.h \
       $$PWD/Gamma/Allocator.h \
       $$PWD/Gamma/Analysis.h \
       $$PWD/Gamma/arr.h \
       $$PWD/Gamma/AudioIO.h \
       $$PWD/Gamma/Config.h \
       $$PWD/Gamma/Constants.h \
       $$PWD/Gamma/Containers.h \
       $$PWD/Gamma/Conversion.h \
       $$PWD/Gamma/Delay.h \
       $$PWD/Gamma/DFT.h \
       $$PWD/Gamma/Domain.h \
       $$PWD/Gamma/Effects.h \
       $$PWD/Gamma/Envelope.h \
       $$PWD/Gamma/FFT.h \
       $$PWD/Gamma/Filter.h \
       $$PWD/Gamma/FormantData.h \
       $$PWD/Gamma/Gamma.h \
       $$PWD/Gamma/gen.h \
       $$PWD/Gamma/HRFilter.h \
       $$PWD/Gamma/ipl.h \
       $$PWD/Gamma/mem.h \
       $$PWD/Gamma/Node.h \
       $$PWD/Gamma/Noise.h \
       $$PWD/Gamma/Oscillator.h \
       $$PWD/Gamma/Print.h \
       $$PWD/Gamma/pstdint.h \
       $$PWD/Gamma/Recorder.h \
       $$PWD/Gamma/rnd.h \
       $$PWD/Gamma/SamplePlayer.h \
       $$PWD/Gamma/Scheduler.h \
       $$PWD/Gamma/scl.h \
       $$PWD/Gamma/SoundFile.h \
       $$PWD/Gamma/Spatial.h \
       $$PWD/Gamma/Strategy.h \
       $$PWD/Gamma/Sync.h \
       $$PWD/Gamma/tbl.h \
       $$PWD/Gamma/Thread.h \
       $$PWD/Gamma/Timer.h \
       $$PWD/Gamma/TransferFunc.h \
       $$PWD/Gamma/Types.h \
       $$PWD/Gamma/UnitMaps.h \
       $$PWD/src/fftpack++.h \
       $$PWD/gamma.h
    
    SOURCES = \
       $$PWD/src/arr.cpp \
       $$PWD/src/AudioIO.cpp \
       $$PWD/src/Conversion.cpp \
       $$PWD/src/DFT.cpp \
       $$PWD/src/Domain.cpp \
       $$PWD/src/FFT_fftpack.cpp \
       $$PWD/src/fftpack++1.cpp \
       $$PWD/src/fftpack++2.cpp \
       $$PWD/src/Print.cpp \
       $$PWD/src/Recorder.cpp \
       $$PWD/src/Scheduler.cpp \
       $$PWD/src/scl.cpp \
       $$PWD/src/SoundFile.cpp \
       $$PWD/src/Timer.cpp
    
    INCLUDEPATH = \
        $$PWD/. \
        $$PWD/external/include \
        $$PWD/Gamma \
        $$PWD/src
    
    DEPENDPATH = \
        $$PWD/. \
        $$PWD/external/include \
        $$PWD/Gamma \
        $$PWD/src
    
    #LibSndFile
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/external/lib_win64/ -llibsndfile-1
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/external/lib_win64/ -llibsndfile-1d
    else:unix: LIBS += -L$$PWD/external/lib_win64/ -llibsndfile-1
    
    INCLUDEPATH += $$PWD/external/lib_win64
    DEPENDPATH += $$PWD/external/lib_win64
    
    #PortAudio
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/external/lib_win64/ -lportaudio_x64
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/external/lib_win64/ -lportaudio_x64d
    else:unix: LIBS += -L$$PWD/external/lib_win64/ -lportaudio_x64
    
    INCLUDEPATH += $$PWD/external/lib_win64
    DEPENDPATH += $$PWD/external/lib_win64
    
    !include(../common.pri) {
        error("common.pri not found")
    }
    
    

  • Lifetime Qt Champion

    Hi @Yosemite, glad you got it working and thanks for reporting back!

    Regards


Log in to reply