Skip to content

the static binding

Orfeo Da Vià edited this page Nov 2, 2021 · 1 revision

The static binding has a link-time dependency on either the shared or the static raylib library. On Windows, you can link with the static library or, to use the shared library (raylib.dll), with the import library.

On other systems, you can link with either the static library or directly with the shared library. This requires the raylib development package be installed on your system at compile time, either by compiling the raylib source yourself, downloading the raylib precompiled binaries for Windows, or installing via a system package manager.

When linking with the static library, there is no run-time dependency on raylib. When linking with the shared library (or the import library on Windows), the run-time dependency is the same as the dynamic binding, the difference being that the shared library is no longer loaded manually—loading is handled automatically by the system when the program is launched.

Enabling the static binding can be done in two ways.

Via the compiler's -version switch

Pass the BindRaylib_Static version to the compiler and link with the appropriate library.

Using the compiler command line or a build system that doesn't support DUB, the -version=BindRaylib_Static option should be passed to the compiler when building your program. All of the required C libraries, as well as the bindbc-raylib3 and bindbc-loader static libraries, must also be passed to the compiler on the command line or via your build system's configuration.

Via DUB's versions directive

Using DUB, set the BindRaylib_Static version via its versions directive and the required libraries in the libs directive. For example:

dub.json

"dependencies": {
    "bindbc-raylib3": "~>0.1.0"
},
"versions": ["BindRaylib_Static"],
"libs": ["libraylib"]

dub.sdl

dependency "bindbc-raylib3" version="~>0.1.0"
versions "BindRaylib_Static"
libs "libraylib"

The above example only links to the raylib library, meaning it is linking with either the shared library or, on Windows, the import library for the DLL. When linking with the raylib static library, any dependencies it has must also be added to the libs directive.