www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Shared library question

reply Dibyendu Majumdar <d.majumdar gmail.com> writes:
Hi

I am trying to create a simple shared library that exports a D 
function, but when I try to link to it I get errors such as:

  error LNK2001: unresolved external symbol _D7xxx12__ModuleInfoZ

Here xxx is the module inside the shared library.

I am using DMD and MS LINKER (Windows 64-bit) to create the DLL / 
LIB files.
Then I am using DMD to build the executable.

In the test program I do following:

module app;
import xxx;

void main() {
   testing(); /* exported from xxx */
}

I cannot figure out what I am doing wrong - any help appreciated.

Regards
Jan 22 2016
parent reply Dibyendu Majumdar <d.majumdar gmail.com> writes:
On Friday, 22 January 2016 at 22:06:35 UTC, Dibyendu Majumdar 
wrote:
 Hi

 I am trying to create a simple shared library that exports a D 
 function, but when I try to link to it I get errors such as:

  error LNK2001: unresolved external symbol _D7xxx12__ModuleInfoZ
I have uploaded my small test here so if anyone can tell me what I am doing wrong it will hugely appreciated. Thanks! https://github.com/dibyendumajumdar/d-lab/tree/master/sharedlib
Jan 22 2016
parent Benjamin Thaut <code benjamin-thaut.de> writes:
On Saturday, 23 January 2016 at 00:38:45 UTC, Dibyendu Majumdar 
wrote:
 On Friday, 22 January 2016 at 22:06:35 UTC, Dibyendu Majumdar 
 wrote:
 Hi

 I am trying to create a simple shared library that exports a D 
 function, but when I try to link to it I get errors such as:

  error LNK2001: unresolved external symbol 
 _D7xxx12__ModuleInfoZ
I have uploaded my small test here so if anyone can tell me what I am doing wrong it will hugely appreciated. Thanks! https://github.com/dibyendumajumdar/d-lab/tree/master/sharedlib
Dll support on windows is basically non existant at the moment and I strongly advice against trying to use it. Trust me I've been there. I'm currently working on propper Dll support but that is most likely going to take a few more months. Your best option currently is to simply link everything statically. Kind Regards Benjamin
Jan 23 2016