Cross-platform dynamic libraries (GNU/Linux, Mac OS X, Windows,...)

Hugues De Keyzer "digitalmars _NO_SPAM_ " at hugues.info
Wed Sep 5 10:00:26 PDT 2007


Hi,

I'm planning to create a multi-platform (at least GNU/Linux, Mac OS X 
and Windows) application in D. One of its key characteristics is that it 
will be based on modules (plug-ins). Ideally, functionalities more 
advanced than just normal shared libraries would be desirable.

I took a look at DDL, but it seems to be targeted only at Windows.

I made some dlopen() tests on Mac OS X 10.4 with gdc. It works, as long 
as the garbage collector isn't involved in the library. Instancing a 
class in the library works only if new() and delete() are defined and 
don't call the gc. When new() and delete() are not defined, instancing a 
class results in a bus error. gdb gives the following message:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x0005389a in _d_newclass ()

I also tried calling std.gc.setGCHandle(), but it also fails:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x00053435 in std.gc.addRange(void*, void*) ()

This may sound like a newbie question, but is there an easy way (or a 
way at all) to develop a cross-platform application in D with shared 
libraries?

Dynamic linking is a very useful feature for software development. 
Including this in the D specification (like threads) would be great.

Hugues De Keyzer

--
The only constant in life is change
    -- www.wikipedia.org



More information about the Digitalmars-d mailing list