D and .lib files. C++/Other?

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 2 01:56:53 PDT 2017


On 2017-07-01 21:11, Damien Gibson wrote:

> As well I only intended to use shared libraries not static ones...

Well, you can use shared libraries in two different way, dynamic linking 
or dynamic loading.

Dynamic linking is when you declare your external symbols as usual and 
you link with the shared library at build time.

Dynamic loading is when you declared your external symbols as function 
pointer and you don't link with the shared libraries at build time. You 
then use "dlopen" and the family of functions on Posix and "LoadLibrary" 
on Windows to load the shared library at runtime.

When using dynamic linking on Posix you link directly with the shared 
library. When using dynamic linking on Windows you don't link directly 
with the shared library but instead link with an import library, which 
is basically a static library (as far as I understand). I would assume 
that this import library has the same problem as any other static library.

When using dynamic loading you don't have to worry about these different 
formats at all.

You can read more about static linking vs dynamic linking vs dynamic 
loading and about the problems with the different formats in the dlang 
blog [1] and here [2].

[1] http://dlang.org/blog/2017/06/26/project-highlight-derelict/
[2] http://derelictorg.github.io/bindings/

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list