shared libs for OSX

bitwise via Digitalmars-d digitalmars-d at puremagic.com
Mon May 25 07:33:40 PDT 2015


I've been reading through the Mach-O docs[1], and it seems that dynamic  
libs are treated the same as static libs in that exported symbols can only  
be defined once, even across dynamically loaded libraries. This is why  
calling rt_init from my dylib ended up calling the one that was already  
defined in the application image. I was able to call the rt_init from the  
dylib by specifically requesting it through dlsym, but then, all the  
global variables it used(_isRuntimeInitialized, etc) still ended up  
resolving to the ones in the application image.

At this point, my impression is that it would be very impractical, if not  
impossible to have separate druntimes for each shared library. Even when  
you do link separate runtimes, dyld still treats all the exported symbols  
as shared.


@Martin
So correct me if I'm wrong, but it seems the _only_ choice is a shared  
druntime for osx.
Could you elaborate a bit on how you've managed to do this for linux?


[1]  
https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachOTopics/0-Introduction/introduction.html

Thanks,

   Bit


More information about the Digitalmars-d mailing list