Libraries dependency : static or dynamic (Architecture)
-
wrote on 1 Apr 2021, 13:15 last edited by
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 ?
-
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 ?
@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.
-
@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.
-
@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.
@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.
-
@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.
wrote on 3 Apr 2021, 10:53 last edited by@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) :) ?
-
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. -
wrote on 5 Apr 2021, 06:24 last edited by
Ok thanks, @Christian-Ehrlicher.
I'll use PRE_TARGETDEPS macro insteat of LIBS in libs, And use LIBS macro in App.++
1/7