Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Libraries dependency : static or dynamic (Architecture)
Forum Updated to NodeBB v4.3 + New Features

Libraries dependency : static or dynamic (Architecture)

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
7 Posts 3 Posters 579 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.
  • C Offline
    C Offline
    cfdev
    wrote on 1 Apr 2021, 13:15 last edited by
    #1

    Hello Programmers !

    What is the best way is this case :
    App -> Lib1
    -> Lib2
    Lib2 depend of Lib1, App use Lib1 and Lib2.

    Currently I use Lib1 et Lib2 in static, but in this case I think that Lib1 is duplicate in the Lib2 and App ? isnt it ?

    S 1 Reply Last reply 2 Apr 2021, 09:25
    0
    • C cfdev
      1 Apr 2021, 13:15

      Hello Programmers !

      What is the best way is this case :
      App -> Lib1
      -> Lib2
      Lib2 depend of Lib1, App use Lib1 and Lib2.

      Currently I use Lib1 et Lib2 in static, but in this case I think that Lib1 is duplicate in the Lib2 and App ? isnt it ?

      S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 2 Apr 2021, 09:25 last edited by
      #2

      @cfdev said in Libraries dependency : static or dynamic (Architecture):

      Currently I use Lib1 et Lib2 in static, but in this case I think that Lib1 is duplicate in the Lib2 and App ? isnt it ?

      During static linking process, the linker always optimizes the resulting binary - unused methods and objects are removed. I'm pretty sure you won't get duplicated symbols either.

      (Z(:^

      C C 2 Replies Last reply 3 Apr 2021, 08:28
      1
      • S sierdzio
        2 Apr 2021, 09:25

        @cfdev said in Libraries dependency : static or dynamic (Architecture):

        Currently I use Lib1 et Lib2 in static, but in this case I think that Lib1 is duplicate in the Lib2 and App ? isnt it ?

        During static linking process, the linker always optimizes the resulting binary - unused methods and objects are removed. I'm pretty sure you won't get duplicated symbols either.

        C Offline
        C Offline
        cfdev
        wrote on 3 Apr 2021, 08:28 last edited by cfdev 4 Mar 2021, 08:29
        #3

        @sierdzio ... I hope :) I'll make some tests to see that
        thanks

        1 Reply Last reply
        0
        • S sierdzio
          2 Apr 2021, 09:25

          @cfdev said in Libraries dependency : static or dynamic (Architecture):

          Currently I use Lib1 et Lib2 in static, but in this case I think that Lib1 is duplicate in the Lib2 and App ? isnt it ?

          During static linking process, the linker always optimizes the resulting binary - unused methods and objects are removed. I'm pretty sure you won't get duplicated symbols either.

          C Online
          C Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 3 Apr 2021, 08:42 last edited by
          #4

          @sierdzio said in Libraries dependency : static or dynamic (Architecture):

          I'm pretty sure you won't get duplicated symbols either.

          Mixing static and dynamic libs is problematic especially when the static lib is used from two different dynamic libs (or executables) since then static allocations in the static lib are duplicated for each shared lib.

          --> Don't mix static and dynamic libs when possible.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          C 1 Reply Last reply 3 Apr 2021, 10:53
          1
          • C Christian Ehrlicher
            3 Apr 2021, 08:42

            @sierdzio said in Libraries dependency : static or dynamic (Architecture):

            I'm pretty sure you won't get duplicated symbols either.

            Mixing static and dynamic libs is problematic especially when the static lib is used from two different dynamic libs (or executables) since then static allocations in the static lib are duplicated for each shared lib.

            --> Don't mix static and dynamic libs when possible.

            C Offline
            C Offline
            cfdev
            wrote on 3 Apr 2021, 10:53 last edited by
            #5

            @Christian-Ehrlicher in fact, I don't mix static and dynamic.

            I just want to know if i'ts better to use dynamic or static lib in this case (lib1 is use in lib2 and App) :) ?

            1 Reply Last reply
            0
            • C Online
              C Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 3 Apr 2021, 15:44 last edited by
              #6

              It does no matter, a static lib does not contain code of another static lib at all - it's more or less just a collection of the compiled object files.
              When you don't need the libraries anywhere else I would go with static libs.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              1
              • C Offline
                C Offline
                cfdev
                wrote on 5 Apr 2021, 06:24 last edited by
                #7

                Ok thanks, @Christian-Ehrlicher.
                I'll use PRE_TARGETDEPS macro insteat of LIBS in libs, And use LIBS macro in App.

                ++

                1 Reply Last reply
                0

                1/7

                1 Apr 2021, 13:15

                • Login

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