1 #ifndef RuntimeLibrary_HH
2 #define RuntimeLibrary_HH
24 std::string _filename_base,
25 std::string _compile_options,
26 std::string _so_options,
27 std::string compile_msg,
37 template<
typename Signature>
38 std::function<Signature>
get_function(std::string function_name)
const {
40 std::function<Signature> func =
reinterpret_cast<Signature *
>(dlsym(
m_handle, function_name.c_str()));
42 const char *dlsym_error = dlerror();
44 throw std::runtime_error(std::string(
"Cannot load symbol " + function_name +
" \n" + dlsym_error));
60 static std::pair<std::string, std::string>
default_cxx();
RuntimeLibrary(std::string _filename_base, std::string _compile_options, std::string _so_options, std::string compile_msg, const Logging &logging=Logging())
Construct a RuntimeLibrary object, with the options to be used for compile the '.o' file and the '...
static std::pair< std::string, std::string > default_cxxflags()
Default c++ compiler options.
void _load()
Load a library with a given name.
static std::pair< fs::path, std::string > default_casm_includedir()
Return default includedir for CASM.
std::string include_path(const fs::path &dir)
std::string link_path(const fs::path &dir)
static std::pair< std::string, std::string > default_cxx()
Return default compiler.
void _close()
Close the current library.
std::string m_compile_options
Write, compile, load and use code at runtime.
Logging(Log &log=default_log(), Log &debug_log=default_log(), Log &err_log=default_err_log())
static std::pair< fs::path, std::string > default_boost_libdir()
Return default libdir for boost.
static std::pair< fs::path, std::string > default_casm_libdir()
Return default libdir for CASM.
static std::pair< std::string, std::string > default_soflags()
Default c++ compiler options.
std::function< Signature > get_function(std::string function_name) const
Obtain a function from the current library.
std::string m_filename_base
void _compile()
Compile a shared library.
void rm()
Remove the current library and source code.
static std::pair< fs::path, std::string > default_boost_includedir()
Return default includedir for boost.