Jump to content

[SOLVED] Plugin path problem


photo

Recommended Posts

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

Link to comment

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.

Link to comment
  • 2 weeks later...

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

Link to comment

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.

Link to comment
×
×
  • Create New...