Sign in to follow this  
Dospro

Using dynamic libraries.

Recommended Posts

( I made this new post with the same content as https://www.gamedev.net/topic/687811-portable-shareddynamic-libraries-with-c-and-cmake/ because for some reason it has 0 views. And has been like 3 days. i'm not sure if it is not even shown.) Hope no one gets mad.

Hi everyone.

I'm working on a project that uses a plug-in-like arquitecture.

Right now i'm working on Linux and to implement the plugins I'm using Shared Objects (.so). I load the plugins with the dl API.

On windows there are dlls which are managed in very different way.

Now, in mac OSX i'm a bit confused. I see there are dylib, so, frameworks and bundles (besides other things).

I'm not sure what's the difference between them and what should I use to implement a plug in.

Can anyone point me in the right direction here?

Thanks.

Share this post


Link to post
Share on other sites

I could see that previous post just fine, it's just that I have no idea about an answer, and I guess that holds for most people here.

Maybe you posted at the wrong site?

 

In addition, I would expect that the concepts you have questions about are explained at the Internet.

Share this post


Link to post
Share on other sites

On a POSIX system, you use the dlopen API like you're using for Linux to dynamically load DSOs.

Mac OS X is a POSIX system.  You don't dynamically load .dylib files, they're a completely different beast used by the runtime link-loader.  You load from bundles, which are DSOs and the equivalent to .so files (which are also available).  The MACH-O binary file format differentiates between the two kinds of shared library in a way that ELF (Linux and BSD) and COFF (MS WIndows) do not.

The DSO on MS Windows is a DLL file and it gets used with the LoadLibrary() call, virtually identical to the POSIX dlopen() call.

Edited by Bregma

Share this post


Link to post
Share on other sites

Hi, Dospro.

I'm not sure I got you correctly, but, if you want to use dynamic libraries with g++ / SDL on Mac OS X, you can use the attached code.

 

The code is a simple example of reloading of a dynamic library for a hot-swapping on OS X. Please, don't hesitate to write me if there's something wrong/misunderstandable. Thank you very much! :-)

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this