A Shared library is a file containing executable functions,
usually written in a low level language like C,
compiled and optimized into machine code for a specific device.
The advantages of using shared libraries include fast execution of complex algorithms,
and the ability to directly access a device's hardware and operating system.
If the specified library file is found inside the app, it will be copied into the application's data folder for the operating system to load, otherwise the operating system will search the standard paths for the file. If no filename extension is given, the standard extension for shared libraries on that operating system will be appended. If the library cannot be found or loaded, then the library object will be Null.
Supported C types are:
void, bool, char, unsigned char, short, unsigned short, int, unsigned int,
long, unsigned long, float, double,
and all their respective pointers, with
long being 64 bits.
Any number of functions can be imported at the same time.
A template literal is useful for C code spanning multiple lines.
Values passed into the function will be converted into their respective C types.
Objects will be passed in as pointers. Typed arrays will point to their array data.
Return values are also converted, with char * returned as a String.
32 bit Windows apps use the __cdecl calling convention with all arguments passed in reverse order on the stack. Windows API functions use the __stdcall convention which must be specified in the function declaration.
Android uses the soft-fp calling convention, which passes floating point values the same way as other arguments, in R0 to R3 first then on the stack.
Linux uses the AMD x64 calling convention, which passes arguments in the 64 bit registers and SSE floating point registers before using the stack.
If your function declaration does not match the actual shared library function and calling convention, web.dev.app will likely crash.
Consider a simple C function compiled into a Windows library called
In other operating systems, the libary might be called
and the EXPORT keyword might not be needed,
Consider two C functions compiled into an Android library called
An app's window title can be directly set using
but this example changes the window title by calling the
SetWindowText function in the Win32 API.