I'm trying to use the precompiled dll's that comes with the irrlicht SDK, either the msvc dll or gcc dll and trying to get it to work under borland's 5.5 free compiler. I'm trying to see if dll interoperability is possible when mixing different development tools. This isn't just for borland -- in the future I might want to get a mingw dll to work with digital mars compiler or msvc compiler or visa versa.
I've considered building irrlicht from source but the borland compiler gives too many warnings and errors. I don't have the time or inclination to hack the source trying to get it to build under borland. On the other hand, if I can get precompiled dll's to work then it could save a lot of time and effort since this could be done for other open source projects and tools etc.
So I googled and did some research online regarding what I'm trying to do. I found these two links particularly helpful for what I'm trying to achieve:
http://chadaustin.me/cppinterface.html
http://www.codeproject.com/KB/cpp/howto ... id=2929651
From checking out the irrlicht header files, it looks like irrlicht uses a similar design layout at the top level. Everything looks good so far, calling host programs should be able to interface with irrlicht by taking advantage of the vtable layout.
I created an import library from the supplied irrlicht.dll binary, ensured the exported naming decorations are workable for my target compiler. I proceed to compile the 01.Hello World demo.
The CreateDevice() function returns an IrrlichtDevice object back to hello world demo. At this point, if I try to call a method on this irrlichtdevice* it results in an exception thrown.
Code: Select all
/* Hello world.cpp
* using irrlicht.dll compiled with mingw gcc compiler
*/
//this line runs ok on both bcc and mingw
//pointer appears valid from stepping through debugger
IrrlichtDevice* device = createDevice( video::EDT_SOFTWARE,
dimension2d<u32>(640, 480), 16,
false, false, false, 0);
//this following line crashes with an exception thrown
//when built with bcc -- but doesn't crash for mingw
//even for a simple function call that returns bool and takes no arguments
device->isFullscreen();
In an attempt to fix this, I moved all the object method invocation into the dll instead as a wrapper. The wrapper merely maps the object methods to the corresponding device object method. That seems to work much better. I step through the program execution and most of the object calls seem to go through fine -- getVideoDriver, getSceneManager, getGUIEnvironment all work, external model files load ok etc. But when it comes time to actually draw the scene, that's when it throws an exception again.
Code: Select all
//main loop of the hello world.cpp demo
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
//this following line throws an exception in bcc!
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
- -if smgr->drawAll() is commented out, then no exception is thrown.
-if no camerascenenode is added to smgr then no exception is thrown.
-or if no mesh is added to smgr, then again no exception is thrown -- everything runs ok but we just have an empty scene with nothing to draw!
Any assistance and suggestions are appreciated. After trying and experimenting for a few days, I could really use some help on how to continue debugging this issue.
Thanks[/url]