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. How can I build an executable AND a library?
Forum Updated to NodeBB v4.3 + New Features

How can I build an executable AND a library?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 1.8k Views 1 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.
  • N Offline
    N Offline
    Nielske87
    wrote on last edited by
    #1

    Hi,

    is it possible to build an executable AND a library in one project?
    It seems like when I add TEMPLATE = lib to my .pro file it no longer builds an executable.

    Grtz. Niels

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You need to use the subdir template and create one project for your executable and one for your library.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Nielske87
        wrote on last edited by
        #3

        I will take a look at the subdir template and how to use it.

        My question refers to an earlier post of mine "Link":http://qt-project.org/forums/viewthread/31923/#140602
        My project is not finished so the executable and the library are changed often and my unittest depend on the library my project generates. So I'm looking for a way to generate an executable and a library at once.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then subdir is the way to go.

          One project for your library with all unit tests within and the other for your application that will use that library. You'll need
          @CONFIG += ordered@

          to start building your library then your application. It will be done in one go.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • N Offline
            N Offline
            Nielske87
            wrote on last edited by
            #5

            Actually it's the other way around.
            My unit test project needs to include the library that my other (application) project builds. So my application project needs to build an executable and then the library. That library needs to be included in my unit test project.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then you're going the wrong way, what you should have is:

              • Build the library
              • Build the unit test
              • Build the application

              The unit test building could even be done as part of the library building

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • N Offline
                N Offline
                Nielske87
                wrote on last edited by
                #7

                And I can realize that with 2 .pro files? And with the use of subdirs?

                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