I am currently trying to find a cross platform plugin type /library for c++ to load classes and code at runtime. Unfortunatelly google could not give me anything really useful so I was wondering if anybody could help me out on that subject. Is there something like that out there?
I actually doubt that there is something like that since even bigger cross platform projects like FreeFrame GL use different DLL types on each OS (.so on linux, .bundle on mac and .dll on win).
Dynamic libs cannot be crossplattform, they are tied to their specific platform.
You can use CMake to unify your build configuration and -process, as it’s capable to generate makefiles for unix, visual studio files for Win and XCode-files for Mac OS X.
To load/unload a dynamic lib you’ll need specialized code for every platform.
Okay, thats what I thought. I hoped there would be a better way. I might end up using java then.
i thought about this a lot more and I dont want to end up using java. are there any other options to load programs at runtime?
Well, there are other scripting languages that have cross-platform packages, such as Lua. Actually, with the luabind library, which lets you bind to C/C++ quite easily and actually adds Object-Orienting to the base Lua functionalities, combined with Lua’s ability to compile the Lua scripts into interpreted bytecode, it might not be that difficult, if you just want to use it for building logic on top of other libraries. However, that wouldn’t work for anything system-level.
But I have come across this conundrum a couple of times, and it seems that the best thing to do is to just use source code and open-source libraries as much as possible. I guess it would be possible to make an oF addon that will abstract the loading of dynamic libraries (ie. DLL’s for Windows, Dylibs (Not bundles, by the way) for Darwin/iPhone/OS X, and Shared Objects for Linux) into a uniform way to load and utilize them. It’s something that may have worth as an addon in the future, but I’m not going to try it right now.
that would be a relly great addon. I just mensioned .bundle because FreeFrameGL uses it for OSX
Please let me know if you have any success. Actually LUA seems to be a good idea too since I would only need some programs loaded at runtime to draw some simple stuff so I don’t need anything on the system level as far as I can tell right now!