27 #include <sys/types.h> 37 #if defined (UNIX) || defined(CYGWIN) 42 #define SO_EXT "dylib" 44 #elif defined (WINDOWS) || defined (CYGWIN) 56 DlWrapper::DlWrapper()
60 DlWrapper::~DlWrapper()
65 int DlWrapper::openLibraries(
const std::string& directory,
const std::string& pattern)
68 string searchPattern = directory +
"/" + pattern;
70 searchPattern = directory +
"/*";
74 for (
size_t i = 0; i < matchingFiles.size(); ++i) {
75 const string& filename = matchingFiles[i];
76 if (find(_filenames.begin(), _filenames.end(), filename) != _filenames.end())
84 #ifndef G2O_LIBRARY_POSTFIX 85 if ((filename.rfind(
string(
"_d.") +
SO_EXT) == filename.length() - 3 -
SO_EXT_LEN)
86 || (filename.rfind(
string(
"_rd.") +
SO_EXT) == filename.length() - 4 -
SO_EXT_LEN)
87 || (filename.rfind(
string(
"_s.") +
SO_EXT) == filename.length() - 3 -
SO_EXT_LEN))
93 if (openLibrary(filename))
100 void DlWrapper::clear()
102 # if defined (UNIX) || defined(CYGWIN) 103 for (
size_t i = 0; i < _handles.size(); ++i) {
104 dlclose(_handles[i]);
106 #elif defined(WINDOWS) 107 for (
size_t i = 0; i < _handles.size(); ++i) {
108 FreeLibrary(_handles[i]);
115 bool DlWrapper::openLibrary(
const std::string& filename)
117 # if defined (UNIX) || defined(CYGWIN) 118 void* handle = dlopen(filename.c_str(), RTLD_LAZY);
123 # elif defined (WINDOWS) 124 HMODULE handle = LoadLibrary(filename.c_str());
133 _filenames.push_back(filename);
134 _handles.push_back(handle);
#define __PRETTY_FUNCTION__
std::vector< std::string > getFilesByPattern(const char *pattern)