Skip to main content
GameDev.net gamedev.net
🔒 Locked

Using dynamic libraries.

Started by Dospro Apr 11, 2017 at 3:08 PM 2 replies 1.8k views
Original Post
Dospro
Dospro

( 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.

Alberth
Alberth

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.

Bregma
Bregma

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.

Stephen M. Webb
Professional Free Software Developer
petya-kurochkin
petya-kurochkin

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! :-)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.