2
0
mirror of https://github.com/boostorg/dll.git synced 2026-02-18 14:02:16 +00:00

load_self example

This commit is contained in:
retf
2014-08-12 10:34:06 -03:00
parent b0650e6fae
commit 08dd279787
2 changed files with 37 additions and 0 deletions

View File

@@ -37,3 +37,7 @@ exe shared_library_load_plugin
exe getting_started
: getting_started.cpp
;
exe load_self
: load_self.cpp
;

33
example/load_self.cpp Normal file
View File

@@ -0,0 +1,33 @@
// Copyright 2011-2012 Renato Tegon Forti.
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
// For more information, see http://www.boost.org
// -------------------------------------------------------------------------------------
// This example shows how to use load_self to load symbols direct on executable
// -------------------------------------------------------------------------------------
#include <boost/plugin.hpp>
#include <iostream>
extern "C" BOOST_SYMBOL_EXPORT int sumexe(int x, int y)
{
return x+y;
}
int main(int argc, char* argv[]) {
std::cout << "Application started" << std::endl;
boost::plugin::shared_library self;
self.load_self();
if(self.search_symbol("f"))
{
boost::function<int(int, int)> sum = self.get<int(int, int)>("sumexe");
std::cout << "Computed Value: " << sum(2,2) << std::endl;
}
}