Index: DllLoader.cpp =================================================================== --- DllLoader.cpp (Revision 9639) +++ DllLoader.cpp (Arbeitskopie) @@ -39,31 +39,40 @@ // note: on Linux, lib is prepended to the SO file name #if OS_UNIX -static const char* prefix = "lib"; +static CStr prefix = "lib"; #else -static const char* prefix = ""; +static CStr prefix = ""; #endif + // our SOs export binary-compatible interfaces across debug and release builds, // but for debugging/performance we prefer to use the same version as the app. -// note: on Windows, the extension is replaced with .dll by dlopen. +static const int nbrSuffixes = 2; #ifndef NDEBUG -static const char* primarySuffix = "_dbg.so"; -static const char* secondarySuffix = ".so"; +static CStr suffixes[nbrSuffixes] = { "_dbg", "" }; #else -static const char* primarySuffix = ".so"; -static const char* secondarySuffix = "_dbg.so"; +static CStr suffixes[nbrSuffixes] = { "", "_dbg" }; #endif +// on osx, in addition to .so dynamic libraries, there are also .dylib libraries +// note: on Windows, the extension is replaced with .dll by dlopen. +#if OS_MACOSX +static const int nbrExtensions = 2; +static CStr extensions[nbrExtensions] = { ".so", ".dylib" }; +#else +static const int nbrExtensions = 1; +static CStr extensions[nbrExtensions] = { ".so" }; +#endif + // (This class is currently only used by 'Collada' and 'AtlasUI' which follow // the naming/location convention above - it'll need to be changed if we want // to support other DLLs.) -static CStr GenerateFilename(const CStr& name, const CStr& suffix) +static CStr GenerateFilename(const CStr& name, const CStr& suffix, const CStr& extension) { CStr n; if (!g_Libdir.empty()) n = g_Libdir + "/"; - n += prefix + name + suffix; + n += prefix + name + suffix + extension; return n; } @@ -95,33 +104,44 @@ // {RTLD_NOW, RTLD_LAZY} must be passed. go with the former because // it is safer and matches the Windows load behavior. const int flags = RTLD_LOCAL|RTLD_NOW; - - CStr filename = GenerateFilename(m_Name, primarySuffix); - m_Handle = dlopen(filename.c_str(), flags); - - char* primaryError = NULL; - - // open failed (mostly likely SO not found) - if (! m_Handle) + CStr filename; + CStr dlopenErrors[nbrSuffixes*nbrExtensions]; + int errorCount=0; + + for(int i=0; i