Horde3D
http://www.horde3d.org/forums/

About the GameEngine, DynLib, porting to Linux
http://www.horde3d.org/forums/viewtopic.php?f=6&t=1208
Page 1 of 1

Author:  MistaED [ 30.07.2010, 16:27 ]
Post subject:  About the GameEngine, DynLib, porting to Linux

Hi all, I guess this is more or less a question to Volker,

The GameEngine or "GaBaCo", looks very decent at first glance, something I'd like to test out on mobiles. The ability to dynamically load in libraries is pretty cool, but I was wondering if this could be pulled out in an easy way. I've only glanced over the code and saw that there's some kind of DynLib loading code from ogre which does this.

Ideally I'd like to just compile the core, and some components (animation, scenegraph, bullet physics, IK, sound) into one single static lib which can by linked into my app. Could I just remove all of the plugin loading or what would be the cleanest way to just emulate this behavior? I've never made code which dynamically loads libraries so I'm not sure how to remove the feature exactly... :)

Thanks!

Author:  Volker [ 30.07.2010, 20:04 ]
Post subject:  Re: About the GameEngine, DynLib, porting to Linux

It should be possible to remove the dynamic loading and replace it with some static function that call all the module registrations in a static lib. The only reason using dynamic libraries was the ability to publish only parts of the gameengine without dependency problems.

Author:  MistaED [ 03.08.2010, 07:15 ]
Post subject:  Re: About the GameEngine, DynLib, porting to Linux

Ok I'm giving it a stab by just having a bunch of #ifdefs... :)

So far for load/unload in DynLib.cpp I've just got dummy "return true" "return false" but to grab the right symbol from the static compiled lib, I have no idea in DynLib.cpp:

void* DynLib::getSymbol( const std::string& strName ) const
{
return (void*)DYNLIB_GETSYM( m_hInst, strName.c_str() );
}

DYNLIB_GETSYM being the OS-specific function calls to grab symbols from a dynamic library handle.

What would I replace this with for static libs already inside the lib/exe?

Thanks!

Author:  AlexL [ 03.08.2010, 09:13 ]
Post subject:  Re: About the GameEngine, DynLib, porting to Linux

The process for dynamic loading is:

- Open the DLL/SharedObject (on Linux: dlopen)
- Get the pointer to a well-known function name (e.g. "dllLoadGamePlugin") (on Linux: dlsym)
- Call the function through the function pointer - this registers the plugin
(same is true for unloading - uses dllUnLoadGamePlugin function name)

Now the question is: how did you compile several modules into one static library.
You should get duplicate symbol errors, because dllLoadGamePlugin is defined in
GameCollisionComponent/main.cpp
GameAnimationComponent/main.cpp
and all other plugins.
Did you put them into a namespace or rename them?
If so, you can entirely skip the dynamic loading, but you have to make sure that you
call the GameAnimationComponent::dllLoadGamePlugin function "manually".

Or did I miss your question?

Author:  MistaED [ 03.08.2010, 10:05 ]
Post subject:  Re: About the GameEngine, DynLib, porting to Linux

Hi AlexL thanks for your reply.

Yeah I stepped back a bit and had a nice think about it. The symbols would conflict you're right, I could've wrapped it in a namespace which would've been better, but instead I made #ifdefs with renamed function calls and made headers for the plugin system to use instead, and called those 4 kinds inside of GamePlugInManager.app and removed the need for DynLib entirely.

I haven't tried compiling yet, I thought I'd tackle that first and then see if I can compile it.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/