# [−][src]Crate libloading

A memory-safer wrapper around system dynamic library loading primitives.

Using this library allows loading dynamic libraries (also known as shared libraries) as well as use functions and static variables these libraries contain.

While the library does expose a cross-platform interface to load a library and find stuff inside it, little is done to paper over the platform differences, especially where library loading is involved. The documentation for each function will attempt to document such differences on the best-effort basis.

Less safe, platform specific bindings are also available. See the `os::platform` module for details.

# Usage

Add a dependency on this library to your `Cargo.toml`:

    [dependencies]
    libloading = "0.5"

Then inside your project

    extern crate libloading as lib;

    fn call_dynamic() -> lib::Result<u32> {
        let lib = lib::Library::new("/path/to/liblibrary.so")?;
        unsafe {
            let func: lib::Symbol<unsafe extern fn() -> u32> = lib.get(b"my_func")?;
            Ok(func())
        }
    }

The compiler will ensure that the loaded `function` will not outlive the `Library` it comes from, preventing a common cause of undefined behaviour and memory safety problems.

## Modules

changelog | Project changelog
os | Unsafe, platform specific bindings to dynamic library loading facilities.

## Structs

Library | A loaded dynamic library.
Symbol | Symbol from a library.

## Type Definitions

Result |

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)