On Tuesday, 22 October 2019 at 07:40:01 UTC, Prokop Hapala wrote:


1) I'm not speaking about OpenGL and SDL specifically (that was just small example which I tried first)

FYI, the BindBC bindings can be configured as dynamic (in which all the of C library functions are declared as function pointers and the C shared library must be loaded manually at runtime) or static (in which the C library functions become normal function declarations with no implementation and there is a link-time dependency on the C static or shared library). The exception is OpenGL, for which there is no static binding.

The dynamic bindings add the overhead of the function pointer declarations when linked. It's insignificant for most of them. The biggest bindbc-opengl, depending on how many extensions you configure (it's extremely high for DerelictGL3 most of the time, as it tends to pull in more extensions).


2) I'm more concerned about how to D compiler links dependencies when it compiles simple .d program (with lot of dependencies).

When using dub, it depends on the package configuration of each dependency. All of the Derelict and BindBC packages, for example, are configured to build as static libraries. It didn't (and doesn't) make sense to me to compile a binding as a shared library. Dub packages can also be configured as shared libraries, or simply as "library" (I haven't investigated what that means). Some might provide custom subconfigurations to choose static or shared.

The biggest overhead with DMD output tends to come from the standard library. On Windows, the static library the only option. IIRC on Linux it's necessary to pass -defaultlib=libphobos2.so to DMD to link the shared lib. I don't know how LDC handles it.

Reply via email to