2 Replies - 837 Views - Last Post: 07 July 2016 - 10:19 AM

#1 poloDD  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 09-July 13

Dynamic linking or dynamic loading for shared libraries ?

Posted 07 July 2016 - 02:24 AM

Hello,

I can't know which solution is best in my situation to link a module to a binary. Either by dynamic linking or by dynamic loading with the DL API.

Knowing that :

1. we can specify a flag for the compilation that indicates whether you want to use or not the functions of the library to link (we can do #ifndef MODULE for example).
2. the library functions are used only once during runtime.

Don't hesitate if need further information.

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Dynamic linking or dynamic loading for shared libraries ?

#2 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1265
  • View blog
  • Posts: 4,979
  • Joined: 09-June 09

Re: Dynamic linking or dynamic loading for shared libraries ?

Posted 07 July 2016 - 08:14 AM

If you are specifying a flag at compile time, why not statically link?
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5825
  • View blog
  • Posts: 19,844
  • Joined: 05-May 12

Re: Dynamic linking or dynamic loading for shared libraries ?

Posted 07 July 2016 - 10:19 AM

Working set bloat if code is only used once during runtime, but the OS has to bring in the process image that includes code that is only used occasionally.

Some linkers (like Microsoft's) can take profiling run data and rearrange the code so that more often used code ends up living in pages that are close together. This then lets the OS only page in the parts of the image into memory that are needed. This effectively reduces the program working set.

If you don't have access to such a linker, then I recommend dynamic loading with delay loading -- again assuming if your linker and/or C runtime library supports this.

If you want to not depend on your linker or C runtime library, then you'll have no recourse but to actually manually dynamically load.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1