How to setup DLL and EXE projects in one VS solution

Rainer Schuetze via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 18 00:10:54 PDT 2017



On 17.05.2017 18:56, Igor wrote:
> At the moment I have:
>
> EXEProject:
>   app.d - it does loadlibrary of dllproj and uses data structures
> defined in dllproj.d (it imports dllproj). On the file system this file
> is under <solutiondir>/platform/win32/ and is defined as module win32.app;
>
> DLLProject
>   dllproj.d - exports functions and contains data structures those
> function use. On file system this file is under <solutiondir>/source and
> is defined as module dllproj;
>
> EXEProject depends on DLLProject. DLL project compiles and builds DLL
> fine but, of course EXE project breaks with an error:
>
> module dllproj is in file dllproj.d which cannot be read.
>
> I could just copy all the structs from dllproj.d to app.d and remove the
> import and I guess it would all work but there has to be a better way to
> structure code so structs are only written in one place?

You have to add an import path to the folder with dllproj inside to the 
project configuration of the exeproject.

If you want to limit the imported code to the declarations, you can 
enable "generate interface headers" and add an import path to these instead.

Sharing data or resources between executable and DLL is currently 
limited to separate ownership as each binary contains its own copy of 
the runtime. (There is currently work being done to have a shared 
runtime, though). You might also run into other cross module dependencies...


More information about the Digitalmars-d-learn mailing list