anthony.liot Posted June 22, 2012 Posted June 22, 2012 i have some problem with loading plugin on OSX, i have my plugin in the path : Plugin Path : /Users/wolfviking/Library/Application Support/ActiPlayer/lib/libPlayerPlug_x64d.dylib i have my application in the path : App Path : /Users/wolfviking/Applications/OnlineActiViewerd.app/Contents/MacOS/ When i launch Unigine my parameter is : -extern_plugin ../../../../Library/Application Support/ActiPlayer/lib/PlayerPlug i put some log inside unigine : EnginePlugins.cpp line 63, // plugin library name StringStack<> library_name = String::basename(name); StringStack<> library_path = String::pathname(name); Log::message("-->"+library_name+"\n"); Log::message("-->"+library_path+"\n"); Log::message("-->%s\n",name); We can see the pathname no have the good number of ../ -->PlayerPlug 17:36:11 -->../../Library/Application Support/ActiPlayer/lib/ 17:36:11 -->../../../../Library/Application Support/ActiPlayer/lib/PlayerPlug 17:36:11 Loading "../../Library/Application Support/ActiPlayer/lib/libPlayerPlug_x64d.dylib"... 17:36:11 EnginePlugins::addPlugin(): can't load "../../Library/Application Support/ActiPlayer/lib/libPlayerPlug_x64d.dylib" library 17:36:11 dlopen(../../Library/Application Support/ActiPlayer/lib/libPlayerPlug_x64d.dylib, 1): image not found
steve3d Posted June 25, 2012 Posted June 25, 2012 modify the function like this: #elif defined(_LINUX) || (_MACOS) || defined(_ANDROID) || defined(_IOS) // get absolute canonicalized plugin path library_path = engine.engine->getAppPath() + library_name; char *path = realpath(library_path.get(), NULL); p.handle = dlopen(path,RTLD_LAZY); if(p.handle != NULL) { p.create_plugin = (CreatePlugin)dlsym(p.handle,"CreatePlugin"); p.release_plugin = (ReleasePlugin)dlsym(p.handle,"ReleasePlugin"); } else { Log::error("EnginePlugins::addPlugin(): can't load \"%s\" library\n%s\n",library_name.get(),dlerror()); return 0; } free(path); #endif Don't have linux/mac to test, but this should work.
steve3d Posted July 9, 2012 Posted July 9, 2012 did you fixed the windows part, it should be this way to handle #ifdef _WIN32 wchar_t wbuf[1024], wpath[_MAX_PATH]; #ifdef _WINRT String::utf8ToUnicode(library_path,wbuf,sizeof(wbuf) / sizeof(wbuf[0])); p.handle = LoadPackagedLibrary(wbuf,0); #else // windows requires backslashes (\), not forward slashes (/) library_path = engine.engine->getAppPath() + library_path; library_path = String::replace(library_path, "/", "\\"); String::utf8ToUnicode(library_path,wbuf,sizeof(wbuf) / sizeof(wbuf[0])); // set canonicalized dll folder for plugin load PathCanonicalizeW(wpath, wbuf); SetDllDirectoryW(wpath); // load the plugin library String::utf8ToUnicode(String::basename(library_name),wbuf,sizeof(wbuf) / sizeof(wbuf[0])); p.handle = LoadLibraryW(wbuf); #endif if(p.handle != NULL) { p.create_plugin = (CreatePlugin)GetProcAddress(p.handle,"CreatePlugin"); p.release_plugin = (ReleasePlugin)GetProcAddress(p.handle,"ReleasePlugin"); } else { Log::error("EnginePlugins::addPlugin(): can't load \"%s\" library %d\n",library_name.get(),GetLastError()); return 0; } #elif defined(_LINUX) || (_MACOS) || defined(_ANDROID) || defined(_IOS) Don't know anything about winrt, but I think it should be the same, the PathCanonicalizeW and SetDllDirectoryW might be available to winrt platform. And if these fixes are included in next release of sdk, you should declare this in manual, that all plugin must be specified with relative path to the Unigine_x64.dll
manguste Posted July 10, 2012 Posted July 10, 2012 Steve, thank you for your suggestion, but it it will work for Windows only. That's not a cross-platform solution since there is no analogue for PathCanonicalizeW() and SetDllDirectoryW() functions. There really was a bug with a plugin path, and it was fixed.
steve3d Posted July 12, 2012 Posted July 12, 2012 Haha, I already said the "Windows part" :) Ok, I'll wait to see the results :)
Recommended Posts