Skip to content

dl #

Description

dl can be used to Dynamically Load a library during runtime. It is a thin wrapper over LoadLibrary on Windows, and dlopen on Unix.

Using it, you can implement a plugin system for your application.

Note > We highly recommend using dl.loader instead of dl directly. > It provides a more user-friendly API in the V way.

Constants #

const rtld_noload = C.RTLD_NOLOAD
const rtld_nodelete = C.RTLD_NODELETE
const rtld_local = C.RTLD_LOCAL
const rtld_global = C.RTLD_GLOBAL
const rtld_lazy = C.RTLD_LAZY
const rtld_now = C.RTLD_NOW
const rtld_next = voidptr(-1)
const dl_ext = get_shared_library_extension()
const version = 1

fn close #

fn close(handle voidptr) bool

close frees a given shared object.

fn dlerror #

fn dlerror() string

dlerror provides a text error diagnostic message for functions in dl it returns a human-readable string, describing the most recent error that occurred from a call to one of the dl functions, since the last call to dlerror()

fn get_libname #

fn get_libname(libname string) string

get_libname returns a library name with the operating system specific extension for shared libraries.

fn get_shared_library_extension #

fn get_shared_library_extension() string

get_shared_library_extension returns the platform dependent shared library extension i.e. .dll on windows, .so on most unixes, .dylib on macos.

fn open #

fn open(filename string, flags int) voidptr

open loads a given dynamic shared object.

fn open_opt #

fn open_opt(filename string, flags int) !voidptr

open_opt tries to load a given dynamic shared object.

fn sym #

fn sym(handle voidptr, symbol string) voidptr

sym returns an address of a symbol in a given shared object.

fn sym_opt #

fn sym_opt(shared_object_handle voidptr, symbol string) !voidptr

sym_opt returns the address of a symbol in a given shared object, if found. Unlike sym, sym_opt returns an option.