Linus Posted October 16, 2012 Share Posted October 16, 2012 (edited) I'm trying to write a C++ plugin to add some to add some functionality of an external dll library into unigine. So what I did was create a Plugin.dll to load into Unigine, and that plugin in turn calls function from the external dll library. My plugin code looks like this: class MyPlugin: public Unigine::Plugin { public: MyPlugin() { } virtual ~MyPlugin() { } virtual int init() { Unigine::Log::warning("HeadtrackingPlugin::init() is called\n"); ExternalLib::do_something(); return 1; } virtual int shutdown() { Unigine::Log::warning("HeadtrackingPlugin::shutdown() is called\n"); return 1; } virtual void update() { } }; extern "C" UNIGINE_API void *CreatePlugin() { return new MyPlugin(); } extern "C" UNIGINE_API void ReleasePlugin(void *plugin) { delete static_cast<MyPlugin*>(plugin); } If I take out the line ExternalLib::do_something(); everything works fine (I see the log messages), but when I leave the line in Unigine crashes without any error messages. There are no error messages in the log file either. I put the external dll in the same folder as the Unigine executable. Does anyone know what could be causing the crash? Edited October 16, 2012 by Linus Link to comment
fonta.romain Posted October 16, 2012 Share Posted October 16, 2012 Could you post the entire source code ? I've made a head tracking system without any problems using Unigine plugins. (Intersense inertia Cube 2 and Razer Hydra) Which hardware / software are you using ? Link to comment
Linus Posted October 16, 2012 Author Share Posted October 16, 2012 This is the entire source: HeadtrackingLibrary.cpp Headtracker.h Headtracker.cpp stdafx.h stdafx.cpp dllmain.cpp targetver.h I'm using a TrackIR5 camera and the Optitrack SDK. Link to comment
fonta.romain Posted October 16, 2012 Share Posted October 16, 2012 Don't see anything that hurts me. Perhaps are you mixing debug build with release one ? Using different common runtime ? If you build a fake standalone application (i.e. not using unigine at all) using your head tracker class, everything works properly ? Link to comment
Linus Posted October 17, 2012 Author Share Posted October 17, 2012 I made a standalone application and it ran without any problems. I found the problem when I compared the project settings of the standalone app and the dll. Turns I just forgot to add a preprocessor definition for the camera SDK in the plugin project. :) The plugin works fine now. Thanks for helping out Link to comment
Recommended Posts