www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D's dll and classes

reply Hipreme <msnmancini hotmail.com> writes:
I have a plenty of questions related to the DLL things, .di files.

Basically: I have a main program which would contain a lot of 
code. I have a secondary program which I want to call code from 
the main program, but it will be compiled as a DLL to the main 
program call a single entry point from that DLL.

I have been able to call that secondary okay, the problem is that 
the main is linked into the secondary in order to call the main 
program code. That causes problems related to initialization (as 
only the main should care) and a big binary size. I tried writing 
only .di file for it, but then it would only get undefined 
symbol. What I expected is:



A constains code
A.di contains interfacing code

B uses A.di interfacing code
B is compiled as a DLL


A loads B
A calls B
Sep 19 2021
parent Paul Backus <snarwin gmail.com> writes:
On Sunday, 19 September 2021 at 12:00:22 UTC, Hipreme wrote:
 Basically: I have a main program which would contain a lot of 
 code. I have a secondary program which I want to call code from 
 the main program, but it will be compiled as a DLL to the main 
 program call a single entry point from that DLL.

 [...] I tried writing only .di file for it, but then it would 
 only get undefined symbol. What I expected is:
You may need to use the [`export` attribute][1] to make symbols in the DLL visible to the main program. [1]: https://dlang.org/spec/attribute.html#visibility_attributes
Sep 19 2021