Interfacing C++ to D --> or better: C++ --> C ---> D (DLL)

evilrat evilrat666 at gmail.com
Sun Mar 30 05:37:54 PDT 2014


On Sunday, 30 March 2014 at 11:16:16 UTC, BeschBesch wrote:
>> have you looked at exported symbols in dll? it may be C++ from 
>> what you said(lib not designed for C++?), so you can try 
>> extern(C++) on D side instead extern(C). or add manually 
>> #ifdef __cplusplus and extern "C" on lib side(if its not that 
>> big of course).
>
> First of all: I started with a C++-dll and tried to declare the 
> functions with extern (C++) --> did not work. Then I switched 
> the compiler to C. As VC++ still uses only C89 as standard you 
> can imagine there is NOTHING C++-ish that could have survived. 
> I also tested this DLL in a C++-application (static) and it 
> worked like a charm.
>
> ALSO:
>> As i suspected that some things written by me could be 
>> responsible for this, I build a test application with three 
>> functions (Test, Test2,Test3), got myself the D-.lib for 
>> statical-linking (implib-Dmd) and tried that one out. The 
>> result: Error 42.
>
> So, actually I am trying to get a DLL containing three 
> single-line test functions to work. What I have already 
> achieved is to load it dynamically, and it worked 
> (Derelict.Util.Loader.SharedLibLoader Class). As I also use the 
> Derelict-packages, I may intend to build a custom loader class 
> as a work-around.

it is not clear for me what are you trying to achieve and 
where/what is error 42. do you want implicit loading? if so, have 
you tried converting lib using coffimpblib tool from 
ftp.digitalmars.com? keep in mind that you don't have to convert 
libs when building in 64 bit mode.


More information about the Digitalmars-d-learn mailing list