Results 1 to 10 of 10

Thread: qmake + subdirectories

  1. #1
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    21
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default qmake + subdirectories

    Hello,

    I would like to get some structure in my project:
    / <- main-sourcecode
    /reader <- import filters
    /writer <- export filters

    I don't need libraries - all should be linked together in one executable.

    I could do this with one big .pro in / which includes reader/... files.
    But normaly this is done with a .pro file in every folder.

    Is there anywhere an example for this?
    Or should I organize my files different?

    thanks,
    niko

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake + subdirectories

    Check the examples directory in your qt installation. There are some examples there.

    Regards

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake + subdirectories

    If you use more than one .pro file, it is assumed that you want to build more than one separate "thing" (subproject). In your case it is of course possible to build the subdirectiories as static libraries which would then be linked with the main application, but if you don't need that functionality, you'll get exactly the same code with a single project file.

  4. #4
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    21
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake + subdirectories

    Quote Originally Posted by marcel View Post
    Check the examples directory in your qt installation. There are some examples there.
    I did that - but they all are independent applications. And I want only one executable out of it.



    If you use more than one .pro file, it is assumed that you want to build more than one separate "thing" (subproject). In your case it is of course possible to build the subdirectiories as static libraries which would then be linked with the main application, but if you don't need that functionality, you'll get exactly the same code with a single project file.
    Ok - i will like to try it with static libraries.

    my subdir-pro:
    Qt Code:
    1. CONFIG += staticlib
    2. TEMPLATE = lib
    3. TARGET = ../reader
    To copy to clipboard, switch view to plain text mode 
    If I build the subdir it creates a libreader.a in the root-directory.

    my root-pro:
    Qt Code:
    1. TEMPLATE=app
    2. LIBS += -L. -lreader
    3. SUBDIRS += reader
    To copy to clipboard, switch view to plain text mode 
    If I build the project if finds and uses the libreader.a file.


    But "SUBDIRS += reader" in the root-pro is ignored. so i have to go manually in alls subdirs and build them. How can I tell the root-pro it should behave like app *and* subdirs (or any other solution?)

    thanks,
    niko

  5. #5
    Join Date
    Jan 2006
    Posts
    369
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake + subdirectories

    Qt Code:
    1. TEMPLATE=app
    2. LIBS += -L. -lreader
    3. SUBDIRS += reader
    To copy to clipboard, switch view to plain text mode 

    is this portable to non gcc compilers?

  6. #6
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    21
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake + subdirectories

    from the qmake-manual:
    Qt Code:
    1. unix:LIBS += -L. -lreader
    2. win32:LIBS += reader.lib
    To copy to clipboard, switch view to plain text mode 
    i guess this way it is portable

    (i currently don't have a mac or windows here to test this)

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake + subdirectories

    Quote Originally Posted by niko View Post
    But "SUBDIRS += reader" in the root-pro is ignored.
    Because it only makes sense for "subdirs" template.

    so i have to go manually in alls subdirs and build them. How can I tell the root-pro it should behave like app *and* subdirs (or any other solution?)
    make two subdirectories and use one to build the library and the other to build the main app. Alternatively you might try this:

    TEMPLATE = subdirs
    SUBDIRS = mainapp.pro reader/reader.pro


    Quote Originally Posted by elcuco View Post
    is this portable to non gcc compilers?
    Partially. The "-L" and "-l" switches are portable but the library name might not be.

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: qmake + subdirectories

    How about simple .pri files for reader and writer?
    J-P Nurmi

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake + subdirectories

    The simplest way is to just put files into two directories and provide relative paths in the .pro file. No additional .pro or .pri files needed

  10. The following user says thank you to wysota for this useful post:

    niko (14th April 2007)

  11. #10
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    21
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake + subdirectories

    Quote Originally Posted by wysota View Post
    The simplest way is to just put files into two directories and provide relative paths in the .pro file. No additional .pro or .pri files needed
    ok, thanks

    i will do it that way....

    niko

Similar Threads

  1. Flex, Bison and qmake
    By Hydragyrum in forum Qt Programming
    Replies: 5
    Last Post: 2nd May 2011, 15:52
  2. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15
  3. qmake to build both 32-bit and 64-bit
    By lni in forum Qt Programming
    Replies: 8
    Last Post: 12th December 2006, 19:35
  4. Replies: 5
    Last Post: 13th March 2006, 20:22
  5. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2006, 23:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.