Wrapped the first instance trying to use dlopen in a posix safety ifdef

This commit is contained in:
Andrew Davis 2019-10-16 07:41:14 +01:00
parent bc7e03e708
commit 8f515b504a

View file

@ -2,7 +2,10 @@
#include <algorithm> // for move
#include <sstream> // for stringstream
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
#include <dlfcn.h> // for dlopen
#endif
#include <fmt/core.h>
#include "xtensor/xadapt.hpp"
@ -277,12 +280,17 @@ void initialize_source()
msg << "Sampling from library source " << settings::path_source << "...";
write_message(msg, 6);
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
// Open the library
void* source_library = dlopen(settings::path_source_library.c_str(),RTLD_LAZY);
if(!source_library) {
std::stringstream msg("Couldnt open source library " + settings::path_source_library);
fatal_error(msg);
}
#else
std::stringstream msg("This feature has not yet been implemented for non POSIX systems");
fatal_error(msg);
#endif
// load the symbol
typedef Particle::Bank (*sample_t)();