#include <iostream>
#include <z/file/execdir.hpp>
#include <z/file/library.hpp>
int main() {
if (!lib.
load(libName)) {
std::cout << "Unable to load lib!" << std::endl;
return -1;
}
auto func = lib.
function<void()>(
"test");
if (!func) {
std::cout << "Unable to load symbol \"test\"." << std::endl;
return -1;
}
std::cout << "Loaded symbol \"test\" as function. Result:" << std::endl;
func();
return 0;
}
A class for loading dynamic libraries.
Definition library.hpp:16
bool unload() noexcept
Unload the dynamic library.
bool load(const zpath &fileName, bool autoExtension=true) noexcept
Load a dynamic library with the given file name.
std::function< T > function(const zpath &symbolName) noexcept
Get a pointer to the function with the given name.
Definition library.hpp:111
zpath execdir() noexcept
Get the directory path of the running executable.
Definition execdir.hpp:11