Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator and static library trouble
QtWS25 Last Chance

QtCreator and static library trouble

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 4 Posters 4.1k Views
  • 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.
  • L Offline
    L Offline
    Lindley
    wrote on last edited by
    #1

    I have two qmake projects, Util and UnitTests. Util builds a static library; UnitTests builds an executable that needs to link in Util.

    I'm new to QtCreator and I'm having trouble figuring out the right way to represent this relationship. Util builds cleanly, but every time I try to build UnitTests, it gives me undefined symbol errors. I know that means the library isn't being linked.

    I tried defining a project dependency of UnitTests on Util. However, that doesn't seem to have solved the problem (perhaps this only affects build order?). In Visual Studio, I know that would have been sufficient, but maybe not in QtCreator. After I added the dependency, the "Build" option changed to "Build without dependencies". I couldn't find a way to build with dependencies, which is what I want.

    I tried selecting "Add Library --> Add Internal Library" to the UnitTests project, but the dropdown list was empty (Util was not in it), and I wasn't sure how to proceed from there.

    I can of course just write the link requirement into the UnitTests.pro file, but that doesn't feel "clean" to me. There has to be a better way to do it.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      ProgrammerJoe
      wrote on last edited by
      #2

      I am having exactly the same problem. Does the static library project have to be marked in some way to get it to show up in the "Internal" library dropdown?

      1 Reply Last reply
      0
      • P Offline
        P Offline
        ProgrammerJoe
        wrote on last edited by
        #3

        I found my answer "here":http://stackoverflow.com/questions/16761508/qt-creator-projects-that-use-other-projects-as-libraries.

        I needed to create a parent project that contains references to the child projects. At that point the child projects could find each other for library references. Mine looks like this:

        @TEMPLATE = subdirs
        CONFIG += ordered
        SUBDIRS = codemodel simpleedit@

        1 Reply Last reply
        0
        • D Offline
          D Offline
          davidrhcp
          wrote on last edited by
          #4

          is the

          SUBDIRS =

          is that the directory of your project and then the lib?

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            I used the approach suggested "here":http://stackoverflow.com/questions/1417776/how-to-use-qmakes-subdirs-template

            Worked for me.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              ProgrammerJoe
              wrote on last edited by
              #6

              SUBDIRS contains the names of the two child projects. It's just the name of the directory each of those projects is contained in.

              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