Skip to content

shared_library shared_library

Alairion edited this page May 8, 2021 · 11 revisions

nes::shared_library::shared_library

Functions

(1) constexpr shared_library() = default;
(2) explicit shared_library(load_current_t);
(3) explicit shared_library(const std::string& path);
(4) shared_library(const shared_library&) = delete;
(5) shared_library(shared_library&& other) noexcept;
  1. Constructs an empty shared library. A default constructed shared library does not represent any object. You must not call load on it.
  2. Constructs a shared library that represents the calling binary. It allows you to dynamically access functions within you executable or your shared library using a literal identifier.
    For executable files, you will probably need to change some linker setting in order to export functions' symbols correctly.
  3. Constructs a shared library that represents the specified binary.
  4. Deleted copy-constructor.
  5. Move constructor. Initializes the new shared library with the content other. After this call, other does no longer represents a valid binary.

Parameters

Name Description
path An UTF-8 encoded string that represents the relative or absolute path where the binary file is located
other An instance of nes::shared_library

Preconditions

path must not be an empty string.

Complexity

  1. Explicit
  2. Explicit

Exceptions

  1. Does not throw
  2. Throw a std::runtime_error if the calling binary can not be loaded as a shared library
  3. Throw a std::runtime_error if the file can not be found or is not a valid binary file
  4. Deleted
  5. Does not throw

Implementation details

  1. On Windows, the calling binary is loaded using GetModuleHandleW(nullptr)
    On Posix systems, the calling binary is loaded using dlopen(nullptr, RTLD_NOW)
  2. On Windows, the library is loaded using LoadLibraryW(...)
    On Posix systems, the library is loaded using dlopen(..., RTLD_NOW)
Clone this wiki locally