//----------------------------------------------------------------------------// static DYNLIB_HANDLE DynLibLoad(const String& name) { DYNLIB_HANDLE handle = 0; // prefer whatever location is set in CEGUI_MODULE_DIR environment var const String envModuleDir(getModuleDirEnvVar()); if (!envModuleDir.empty()) handle = DYNLIB_LOAD(envModuleDir + '/' + name); if (!handle) #ifdef __APPLE__ // on apple, look in the app bundle frameworks directory handle = DYNLIB_LOAD("@executable_path/../Frameworks/" + name); if (!handle) #endif // try loading without any explicit location (i.e. use OS search path) handle = DYNLIB_LOAD(name); // finally, try using the compiled-in module directory if (!handle) handle = DYNLIB_LOAD(CEGUI_MODULE_DIR + name); return handle; }
//----------------------------------------------------------------------- void DynLib::load() { // Log library load LogManager::getSingleton().logMessage("Loading library " + mName); String name = mName; #if OGRE_PLATFORM == OGRE_PLATFORM_EMSCRIPTEN if (name.find(".js") == String::npos) name += ".js"; #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_NACL // dlopen() does not add .so to the filename, like windows does for .dll if (name.find(".so") == String::npos) { name += ".so."; name += StringConverter::toString(OGRE_VERSION_MAJOR) + "."; name += StringConverter::toString(OGRE_VERSION_MINOR) + "."; name += StringConverter::toString(OGRE_VERSION_PATCH); } #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE // dlopen() does not add .dylib to the filename, like windows does for .dll if (name.substr(name.find_last_of(".") + 1) != "dylib") name += ".dylib"; #elif OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT // Although LoadLibraryEx will add .dll itself when you only specify the library name, // if you include a relative path then it does not. So, add it to be sure. if (name.substr(name.find_last_of(".") + 1) != "dll") name += ".dll"; #endif #ifdef _UNICODE std::wstring wStr(name.begin(), name.end()); mInst = (DYNLIB_HANDLE)DYNLIB_LOAD(wStr.c_str()); #else mInst = (DYNLIB_HANDLE)DYNLIB_LOAD(name.c_str()); #endif #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE if (!mInst) { // Try again as a framework mInst = (DYNLIB_HANDLE)FRAMEWORK_LOAD(mName); } #endif if (!mInst) OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Could not load dynamic library " + mName + ". System Error: " + dynlibError(), "DynLib::load"); }
//----------------------------------------------------------------------- void DynLib::load() { // Log library load LogManager::getSingleton().logMessage("Loading library " + mName); String name = mName; #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_NACL // dlopen() does not add .so to the filename, like windows does for .dll if (name.find(".so") == String::npos) name += ".so"; #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE // dlopen() does not add .dylib to the filename, like windows does for .dll if (name.substr(name.length() - 6, 6) != ".dylib") name += ".dylib"; #elif OGRE_PLATFORM == OGRE_PLATFORM_WIN32 // Although LoadLibraryEx will add .dll itself when you only specify the library name, // if you include a relative path then it does not. So, add it to be sure. if (name.substr(name.length() - 4, 4) != ".dll") name += ".dll"; #endif mInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() ); if( !mInst ) OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Could not load dynamic library " + mName + ". System Error: " + dynlibError(), "DynLib::load" ); }
// 载入动态库 bool CDynamicLib::Load(const SVString& pszLibName) { ILogManage::GetSingleton().RecordLog("加载动态库" + pszLibName); SVString strName = pszLibName; m_strName = pszLibName; #if SIMVIEW_PLATFORM == SIMVIEW_PLATFORM_LINUX || SIMVIEW_PLATFORM == SIMVIEW_PLATFORM_NACL // dlopen() does not add .so to the filename, like windows does for .dll if (strName.find(".so") == SVString::npos) pszLibName += ".so"; #elif SIMVIEW_PLATFORM == SIMVIEW_PLATFORM_APPLE // dlopen() does not add .dylib to the filename, like windows does for .dll if (strName.substr(strName.length() - 6, 6) != ".dylib") strName += ".dylib"; #elif SIMVIEW_PLATFORM == SIMVIEW_PLATFORM_WIN32 // Although LoadLibraryEx will add .dll itself when you only specify the library name, // if you include a relative path then it does not. So, add it to be sure. if (strName.substr(strName.length() - 4, 4) != ".dll") strName += ".dll"; #endif m_hInsLib = (DYNLIB_HANDLE)DYNLIB_LOAD(strName.c_str()); if (!m_hInsLib) { SIMVIEW_EXCEPT( CSVExpection::ERR_INTERNAL_ERROR, \ "不能打开动态库" + m_strName + \ ". 系统错误码 " + GetLastError(), \ "DynLib::load"); } return (true); }
//##ModelId=4C5A6F7600F1 bool CPluginDll::Load() { String name = m_Name; m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() ); return (m_hInst!=NULL); }
//----------------------------------------------------------------------- bool DynLib::load() { // Already loaded ? if( m_hInst != 0x0 ) return true; // Log library load GameLog::logMessage("Loading library %s", m_name.c_str()); std::string name = m_name; #if defined PLATFORM_LINUX // dlopen() does not add .so to the filename, like windows does for .dll // if (name.substr(name.length() - 3, 3) != ".so") // name += ".so"; #endif m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() ); if( m_hInst == 0x0 ) { GameLog::errorMessage( "Could not load dynamic library %s. System Error: %s", m_name.c_str(), dynlibError().c_str() ); return false; } return true; }
bool NFCDynLib::Load() { std::string strLibPath = "./"; strLibPath += mstrName; mInst = (DYNLIB_HANDLE)DYNLIB_LOAD(strLibPath.c_str()); return mInst != NULL; }
void DynLib::load() { if(m_hInst) return; m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD(mName.c_str()); if(!m_hInst) { BS_EXCEPT(InternalErrorException, "Could not load dynamic library " + mName + ". System Error: " + dynlibError()); } }
//----------------------------------------------------------------------- void DynLib::load() { // Log library load LogManager::getSingleton().logMessage("Loading library " + mName); std::string name = mName; #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX // dlopen() does not add .so to the filename, like windows does for .dll if (name.substr(name.length() - 3, 3) != ".so") name += ".so"; #endif m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() ); if( !m_hInst ) OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Could not load dynamic library " + mName + ". System Error: " + dynlibError(), "DynLib::load" ); }
bool cPluginManager::installPlugin(const char* filename, const char* name) { DYNLIB_HANDLE m_hInst = DYNLIB_LOAD(filename); if(m_hInst) { GetPluginModule moduleFunc = (GetPluginModule)DYNLIB_GETSYM(m_hInst, "GetPluginModule"); if(moduleFunc) { IAudioPlugin* plugin = moduleFunc(CAUDIO_VERSION); if(plugin) { DynamicallyLoadedPlugins[plugin] = m_hInst; return installPlugin(plugin, name); } } else getLogger()->logError("cPluginManager", "installPlugin Error: %s.", getError().c_str()); } return false; }
bool cPluginManager::installPlugin(const char* filename, const char* name) { #ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT DYNLIB_HANDLE m_hInst = DYNLIB_LOAD(filename); if(m_hInst) { GetPluginModule moduleFunc = (GetPluginModule)DYNLIB_GETSYM(m_hInst, "GetPluginModule"); if(moduleFunc) { IAudioPlugin* plugin = moduleFunc(CAUDIO_VERSION); if(plugin) { DynamicallyLoadedPlugins[plugin] = m_hInst; return installPlugin(plugin, name); } } } #endif return false; }
DynamicModule::DynamicModule(const String& name) : d_moduleName(name) { //If nothing is passed, don't load anything... if(name.empty()) { d_handle = 0; return; } // if(name.empty()) #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__HAIKU__) #if defined(CEGUI_HAS_VERSION_SUFFIX) || defined(CEGUI_HAS_BUILD_SUFFIX) // check if we are being asked to open a CEGUI .so, if so postfix the // name with our package version if (d_moduleName.substr(0, 5) == "CEGUI" || d_moduleName.substr(0, 8) == "libCEGUI") { // strip .so extension before postfixing, will get added again below if (d_moduleName.substr(d_moduleName.length() - 3, 3) == ".so") d_moduleName = d_moduleName.substr(0, d_moduleName.length() - 3); #ifdef CEGUI_HAS_BUILD_SUFFIX // append a suffix (like _d for debug builds, etc) d_moduleName += CEGUI_BUILD_SUFFIX; #endif #ifdef CEGUI_HAS_VERSION_SUFFIX d_moduleName += "-"; d_moduleName += CEGUI_VERSION_SUFFIX; #endif } #endif // dlopen() does not add .so to the filename, like windows does for .dll if (d_moduleName.substr(d_moduleName.length() - 3, 3) != ".so") d_moduleName += ".so"; #endif // Optionally add a _d to the module name for the debug config on Win32 #if defined(__WIN32__) || defined(_WIN32) // if name has .dll extension, assume it's complete and do not touch it. if (d_moduleName.substr(d_moduleName.length() - 4, 4) != ".dll") { #ifdef CEGUI_HAS_BUILD_SUFFIX // append a suffix (like _d for debug builds, etc) d_moduleName += CEGUI_BUILD_SUFFIX; #endif #ifdef CEGUI_HAS_VERSION_SUFFIX d_moduleName += "-"; d_moduleName += CEGUI_VERSION_SUFFIX; #endif } #endif d_handle = DYNLIB_LOAD(d_moduleName.c_str()); #if defined(__linux__) || defined(__MINGW32__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__HAIKU__) if (!d_handle) { // see if we need to add the leading 'lib' if (d_moduleName.substr(0, 3) != "lib") { d_moduleName.insert(0, "lib"); d_handle = DYNLIB_LOAD(d_moduleName.c_str()); } } #endif // check for library load failure if (!d_handle) CEGUI_THROW(GenericException( "DynamicModule::DynamicModule - Failed to load module '" + d_moduleName + "': " + getFailureString())); }
bool DynamicLibrary::load() { _handle = (DynLibHandle) DYNLIB_LOAD(_name.c_str()); return _handle != 0; }