2
0
mirror of https://github.com/boostorg/dll.git synced 2026-01-25 06:12:08 +00:00

Fix "Factory method in plugin" example and modernize all the examples (#86)

Fixes https://github.com/apolukhin/Boost.DLL/issues/62
This commit is contained in:
Antony Polukhin
2024-12-22 13:15:43 +03:00
committed by GitHub
parent 96ee80d134
commit f71d8e7bd7
15 changed files with 42 additions and 48 deletions

View File

@@ -17,10 +17,9 @@ namespace dll = boost::dll;
int main(int argc, char* argv[]) {
/*<-*/ b2_workarounds::argv_to_path_guard guard(argc, argv); /*->*/
boost::dll::fs::path lib_path(argv[1]); // argv[1] contains path to directory with our plugin library
boost::shared_ptr<my_plugin_api> plugin; // variable to hold a pointer to plugin variable
std::cout << "Loading the plugin" << std::endl;
plugin = dll::import_symbol<my_plugin_api>( // type of imported symbol is located between `<` and `>`
auto plugin = dll::import_symbol<my_plugin_api>( // type of imported symbol is located between `<` and `>`
lib_path / "my_plugin_sum", // path to the library and library name
"plugin", // name of the symbol to import
dll::load_mode::append_decorations // makes `libmy_plugin_sum.so` or `my_plugin_sum.dll` from `my_plugin_sum`