danni.coy Posted August 4, 2011 Share Posted August 4, 2011 I am trying to get a very simple working plugin. It does very little. #include <Unigine.h> #include <UniginePlugin.h> #include <UnigineInterpreter.h> using namespace Unigine; void print_me_function(const char *str) { Log::warning("print_me_function(\"%s\") called\n",str); } class ai3dPlugin : public Plugin { public: ai3dPlugin() {} virtual ~ai3dPlugin(); virtual int init(); virtual int shutdown(); virtual void update(); }; int ai3dPlugin::init() { Log::warning("Ai3DExtern::init: called\n"); Interpreter::addExternFunction("print_me_function",MakeExternFunction(&print_me_function)); return 1; } int ai3dPlugin::shutdown() { return 1; } void ai3dPlugin::update() { return; } extern "C" UNIGINE_API void *CreatePlugin() { return new ai3dPlugin(); } extern "C" UNIGINE_API void *ReleasePlugin(void *plugin) { delete static_cast<ai3dPlugin*>(plugin); } I compiled with g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -I. -I../include -o ai3d.o ai3d.cpp and linked with g++ -Wl,-O1 -shared -Wl,-soname,libAi3DExtern_x64d.so.1 -o libAi3DExtern_x64d.so.1.0.0 ai3d.o -L/usr/lib -L../lib -lUnigine_x64d -lpthread (taken from the Interface plugin which I was able to successfully compile and run). the resulting libAi3DExtern_x64d.so.1.0.0 is copied to [unigine_root]/lib and ln -s is used to create symbolic links to libAi3DExtern_x64d.so.1.0, libAi3DExtern_x64d.so.1 and libAi3DExtern_x64d.so. When I try to run Ungine with the following sh script. #!/bin/sh export LD_LIBRARY_PATH=../lib:$LD_LIBRARY_PATH ../bin/main_x64d -video_app opengl -sound_app openal \ -extern_define SKIP_BUILTIN -extern_define AI3D \ -extern_plugin Interface \ -extern_plugin Ai3DExtern \ -data_path ../ -engine_config ../data/ai3d/config/global_settings.cfg -console_command "world_load danni" \ -video_mode -1 -video_width 1866 -video_height 1080 -video_multisample 0 -video_fullscreen 0 I get the following error. Loading "libAi3DExtern_x64d.so"... EnginePlugins::addPlugin(): can't load "libAi3DExtern_x64d.so" library I am using gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) Link to comment
hintuc_de Posted August 4, 2011 Share Posted August 4, 2011 Try link plugin with -static option. I had some problems with Network plugin, when it couldn't to find RakNet.dll, it write: Loading "Network....dll"... EnginePlugins::addPlugin(): can't load "Network....dll" library Link to comment
danni.coy Posted August 4, 2011 Author Share Posted August 4, 2011 Try link plugin with -static option. I had some problems with Network plugin, when it couldn't to find RakNet.dll, it write: Loading "Network....dll"... EnginePlugins::addPlugin(): can't load "Network....dll" library Compiling with static doesn't seem to fix the problem. There shouldn't be any dependencies other than libUnigine Link to comment
Guest anet Posted August 5, 2011 Share Posted August 5, 2011 Is this plugin located in the same directory as the main executable? The case is that executable searches for plugin relatively to its own directory. Link to comment
Guest anet Posted August 5, 2011 Share Posted August 5, 2011 Try link plugin with -static option. I had some problems with Network plugin, when it couldn't to find RakNet.dll, it write: Loading "Network....dll"... EnginePlugins::addPlugin(): can't load "Network....dll" library RakNet.dll should be put to the path where the system can find it. (added to PATH environment variable in Windows, to LD_LIBRARY_PATH in Linux or in the same directory as main executable). Link to comment
danni.coy Posted August 5, 2011 Author Share Posted August 5, 2011 Is this plugin located in the same directory as the main executable? The case is that executable searches for plugin relatively to its own directory. The plugin (a shared library) was placed in the lib folder... Same place I put libInterface.so Link to comment
Guest anet Posted August 5, 2011 Share Posted August 5, 2011 The plugin (a shared library) was placed in the lib folder... Same place I put libInterface.so In this case you probably need to specify not only the plugin name but the path too. The path should be relative to the main executable. This is an example: -extern_plugin ../../plugins/Network/lib/Network However it is strange, if interface plugin worked well from this folder and this plugin does not... Link to comment
danni.coy Posted August 5, 2011 Author Share Posted August 5, 2011 In this case you probably need to specify not only the plugin name but the path too. The path should be relative to the main executable. This is an example: -extern_plugin ../../plugins/Network/lib/Network However it is strange, if interface plugin worked well from this folder and this plugin does not... Given that the script is manipulating LD_LIBRARY_PATH on Linux, libraries should be picked up in that folder automatically (if I understand the dynamic linker on linux at all). I tried your suggestion of adding the relative path to the plugin but no improvements in the situation. Link to comment
Guest anet Posted August 5, 2011 Share Posted August 5, 2011 Have you tried to use only one "extern_plugin" option, and set both plugin names there (separating them by comma)? -extern_plugin Interface,Ai3DExtern Link to comment
danni.coy Posted August 5, 2011 Author Share Posted August 5, 2011 Have you tried to use only one "extern_plugin" option, and set both plugin names there (separating them by comma)? -extern_plugin Interface,Ai3DExtern That fixed some problems I was obviously going to have (console now shows it trying to load both libraries). However it still won't load my library Link to comment
danni.coy Posted August 9, 2011 Author Share Posted August 9, 2011 Would it help if I uploaded the .so file... Link to comment
manguste Posted August 22, 2011 Share Posted August 22, 2011 Please check source/samples/Api/Plugins/plugin for Makefile reference. For example, -soname is not necessary. Link to comment
Recommended Posts