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

How to add a folder to my project?



  • Hello all,
    I have a project "MachineSimulation". I have copied a folder called "Linux" into my project folder. "Linux" is a sample folder with subfolders and several files inside it which was provided by the developer and I just need to add the folder to my project and test it.
    I tried SUBDIRS in my project .pro file but I don't see the folder added to my project. Also I got an error saying "No .pro file found in Linux folder".

    Can anyone help me out please?
    I have attached images of "MachineSimulation" project folder and "Linux" folder which has to be included https://postimg.cc/gallery/jbgYmxs


  • Lifetime Qt Champion

    Hi,

    What exactly do you want to do with these files ?
    Build them independently as an application/library ?
    Integrate them in your own project ?



  • @SGaist Hey, Thanks for your reply. I would like to integrate them in my project. But, building them as a library also sounds good. Can you tell me how to do them both ways please :)


  • Lifetime Qt Champion

    For project integration, don not use SUBDIRS but create a .pri file that you include in your .pro file and in which you add the files required and link to the required libraries as well.

    For the SUDBDIRS part, create a lib project as you would any other, add the required files, link to the required library.

    You'll likely have to take inspiration from the Makefile to see what is required to build whatever is in that folder.



  • @SGaist hey, Can you please elaborate a little more on 'adding the files and linking to required libraries'?
    Now I have created a .pri file and I have included it in my .pro file.
    Do I have to add the files from the folder to my project and to the .pri file?

    P:S: This link says to add a subfolder and add files in it and include them in .pri file. Is this what you mean? https://programmersought.com/article/50724387458/


  • Lifetime Qt Champion

    @sudharsan10 said in How to add a folder to my project?:

    Do I have to add the files from the folder to my project and to the .pri file?

    As stated you need to add them to the pri file, there is no point in adding it to both. To add source code files see SOURCES and HEADERS variables in qmake documentation. Libs: https://doc.qt.io/qt-5/qmake-variable-reference.html#libs


Log in to reply