Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Building .pro as library - suggestions ?
Forum Updated to NodeBB v4.3 + New Features

Building .pro as library - suggestions ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 265 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    When I build a project as TEMPLATE=lib I no longer have an option to "run" such project.
    I can add then build library to my main subproject and keep editing and rebuilding it as necessary.

    What would be a reasonable way to be able to test the subproject as before , as "app"?

    Someting likes
    #ifdef app
    run project as app
    #else
    use project as lib
    #endif

    afee423e-f6bd-40d4-9a03-5b471a1d1c27-image.png

    Gojir4G 1 Reply Last reply
    0
    • A Anonymous_Banned275

      When I build a project as TEMPLATE=lib I no longer have an option to "run" such project.
      I can add then build library to my main subproject and keep editing and rebuilding it as necessary.

      What would be a reasonable way to be able to test the subproject as before , as "app"?

      Someting likes
      #ifdef app
      run project as app
      #else
      use project as lib
      #endif

      afee423e-f6bd-40d4-9a03-5b471a1d1c27-image.png

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @AnneRanch What about making a project dedicated for testing your library ? So things are kept separated and you can also test importing the library into a "root" project.

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        An app is a program that has a main() function. A library is just a bunch of functions exported to be used by another project. Switching between them in a single project is not something that is usually done. What would happen to the main() function if you treat it as a library? What if that main contains important functionality e.g. in case of Qt apps starts an event loop? You can't just skip that if you treat it as a library, or, if you do skip it, you would have to duplicate the same functionality in the actual app. It would be a big waste.

        The scenario you described is a common thing when you talk about testing. Basically you have 3 projects:

        • A library with all the functionality.
        • The main application which links that library. It has a main() function that does the basic setup and runs that library code.
        • A test framework application that links to the library and runs tests on individual functions from it.

        In such setup you don't have to switch anything or do any extra work. You just run either the main app or the testing app. Both use the same library.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          I think that is a solution. That way I can keep editing the source ans still run the "library" a stand alone project -
          as long as I keep the "inlcude(s) " happy . .
          I'll give a go.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved