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. General question on linking libraries

General question on linking libraries

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 806 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.
  • A Offline
    A Offline
    aethelnorn
    wrote on last edited by
    #1

    If I am in a subdirs project, and building two static libs where libA depends on libB, should I expect libA.a to be larger than libB.a, ie should the static library contain the code for the static library it depends upon? Or am I getting muddled here?

    In my case libA.a is ~16kB and liB.a is about 327kB. Now if the linking is sufficiently clever it could eliminate a lot of unused code, but that seems a bit of a stretch for my imagination. I am more inclined to believe that I have got the build wrong somehow......

    Could someone clear some of the fog for me pleas?

    aha_1980A 1 Reply Last reply
    0
    • A aethelnorn

      If I am in a subdirs project, and building two static libs where libA depends on libB, should I expect libA.a to be larger than libB.a, ie should the static library contain the code for the static library it depends upon? Or am I getting muddled here?

      In my case libA.a is ~16kB and liB.a is about 327kB. Now if the linking is sufficiently clever it could eliminate a lot of unused code, but that seems a bit of a stretch for my imagination. I am more inclined to believe that I have got the build wrong somehow......

      Could someone clear some of the fog for me pleas?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @aethelnorn The final link step is done when the executable and all depending libs are put together.

      Unti then, the linker cannot know which function from the library you are possibly using or not, and therefore needs to keep them all in.

      Qt has to stay free or it will die.

      A 1 Reply Last reply
      2
      • aha_1980A aha_1980

        @aethelnorn The final link step is done when the executable and all depending libs are put together.

        Unti then, the linker cannot know which function from the library you are possibly using or not, and therefore needs to keep them all in.

        A Offline
        A Offline
        aethelnorn
        wrote on last edited by
        #3

        @aha_1980 OK, so I have libA.a and libB.a and no code from libB has yet been included in libA. That makes sense. But what if libA.a were the ultimate product of this build? It would then need libB included in it. How could I tell the system that this was the case?

        Another possibility in my case is that libA does include libB but uses so little of it that the size of libA does not increase much atall. I could almost beleive that (but not quite as the discrepency is large). Mind you, I have little feel for how much code 8kB represents.

        aha_1980A 1 Reply Last reply
        0
        • A aethelnorn

          @aha_1980 OK, so I have libA.a and libB.a and no code from libB has yet been included in libA. That makes sense. But what if libA.a were the ultimate product of this build? It would then need libB included in it. How could I tell the system that this was the case?

          Another possibility in my case is that libA does include libB but uses so little of it that the size of libA does not increase much atall. I could almost beleive that (but not quite as the discrepency is large). Mind you, I have little feel for how much code 8kB represents.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @aethelnorn said in General question on linking libraries:

          @aha_1980 OK, so I have libA.a and libB.a and no code from libB has yet been included in libA. That makes sense. But what if libA.a were the ultimate product of this build? It would then need libB included in it. How could I tell the system that this was the case?

          I'm not absolutely sure here, but I think that static libs are never a final target, only shared libs or programs.

          Another possibility in my case is that libA does include libB but uses so little of it that the size of libA does not increase much atall. I could almost beleive that (but not quite as the discrepency is large). Mind you, I have little feel for how much code 8kB represents.

          Well, with my embedded background, that could be a complete program on a microcontroller ;)

          Otherwise, really hard to tell

          Qt has to stay free or it will die.

          A 2 Replies Last reply
          1
          • aha_1980A aha_1980

            @aethelnorn said in General question on linking libraries:

            @aha_1980 OK, so I have libA.a and libB.a and no code from libB has yet been included in libA. That makes sense. But what if libA.a were the ultimate product of this build? It would then need libB included in it. How could I tell the system that this was the case?

            I'm not absolutely sure here, but I think that static libs are never a final target, only shared libs or programs.

            Another possibility in my case is that libA does include libB but uses so little of it that the size of libA does not increase much atall. I could almost beleive that (but not quite as the discrepency is large). Mind you, I have little feel for how much code 8kB represents.

            Well, with my embedded background, that could be a complete program on a microcontroller ;)

            Otherwise, really hard to tell

            A Offline
            A Offline
            aethelnorn
            wrote on last edited by
            #5

            @aha_1980 said in General question on linking libraries:

            @aethelnorn said in General question on linking libraries:

            @aha_1980 OK, so I have libA.a and libB.a and no code from libB has yet been included in libA. That makes sense. But what if libA.a were the ultimate product of this build? It would then need libB included in it. How could I tell the system that this was the case?

            I'm not absolutely sure here, but I think that static libs are never a final target, only shared libs or programs.
            That would make sense, in a limited way. Static libs could be viewd as 'intermediates' and not final products. Does seem a bit limited if I were producing them for a JNI app. Or would that require dynamic libs? My ignorance shows through.

            Another possibility in my case is that libA does include libB but uses so little of it that the size of libA does not increase much atall. I could almost beleive that (but not quite as the discrepency is large). Mind you, I have little feel for how much code 8kB represents.

            Well, with my embedded background, that could be a complete program on a microcontroller ;)

            I know..... at college we wrote a pre-emptive multitasking operating system on a board with 1k and a 6800. Needed the only 4k board to run the debugger...

            Otherwise, really hard to tell

            I will worry about whether this step is successful once I get to the next step then.

            1 Reply Last reply
            0
            • aha_1980A aha_1980

              @aethelnorn said in General question on linking libraries:

              @aha_1980 OK, so I have libA.a and libB.a and no code from libB has yet been included in libA. That makes sense. But what if libA.a were the ultimate product of this build? It would then need libB included in it. How could I tell the system that this was the case?

              I'm not absolutely sure here, but I think that static libs are never a final target, only shared libs or programs.

              Another possibility in my case is that libA does include libB but uses so little of it that the size of libA does not increase much atall. I could almost beleive that (but not quite as the discrepency is large). Mind you, I have little feel for how much code 8kB represents.

              Well, with my embedded background, that could be a complete program on a microcontroller ;)

              Otherwise, really hard to tell

              A Offline
              A Offline
              aethelnorn
              wrote on last edited by
              #6

              @aha_1980 Yep, it was not completely linking.... next step gate an executable large enough to convince me - and executable runs so must have all the libs in it. Thanks again for your help.

              1 Reply Last reply
              1

              • Login

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