Skip to content

link_library

Declaration

link_library :: fn (assembly: Assembly, name: string)

Description

Add system library. Only name is required (without extension and prefix). Compiler will lookup for this library in working directory, system PATH and LINKER_LIB_PATH variable specified in bl.conf file. Linked library can be used also during compile-time execution, in such case all needed symbols are loaded in compile-time. This does not work for .lib files on Windows.

Arguments

  • assembly Target assembly.
  • name Library name.
    • On Linux name will be extended by 'lib' prefix and '.so' extension.
    • On MacOS name will be extended by 'lib' prefix and '.dylib' extension.
    • On Windows name will be extended only by '.dll' extension.

Example

build :: fn () #build_entry {
    exe :: add_executable("MyGame");
    add_unit(exe, "src/main.bl");

    switch OS_KIND {
        OSKind.Windows { target_windows(exe); }
        default        { panic("Unknown build target!"); }
    }
}

target_windows :: fn (exe: Assembly) {
    link_library(exe, "freetype");
    link_library(exe, "zlib");
    link_library(exe, "png");
}

Declared in: build.bl