-
-string library(const string& theLibName)
-{
- string aLibName = theLibName;
-
-#ifndef WIN32
- static string aLibExt( ".so" );
- if (aLibName.size() < 3 || aLibName.substr(0, 3) !="lib")
- aLibName = "lib" + aLibName;
-#else
- static string aLibExt( ".dll" );
-#endif
-
- string anExt = aLibName.substr(aLibName.size() - 4);
-
- if ( anExt != aLibExt)
- aLibName += aLibExt;
-
- return aLibName;
-}
-
-// for debug purpose only (cerr), before the error management system is implemented
-#include <iostream>
-void ModelAPI_PluginManager::loadLibrary(const string theLibName)
-{
- string aFileName = library(theLibName);
- if ( aFileName.empty() )
- {
- cerr<<"Library "<<theLibName.c_str()<<" can not be imported"<<endl;
- return;
- }
-
-#ifdef WIN32
- HINSTANCE aModLib = ::LoadLibrary( aFileName.c_str() );
- if (!aModLib)
- cerr<<"Failed to load "<<aFileName.c_str()<<endl;
-#else
- void* aModLib = dlopen( aFileName.c_str(), RTLD_LAZY );
- if ( !aModLib )
- cerr<<"Failed to load "<<aFileName.c_str()<<endl;
-#endif
-}