www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Using MinGW DLL with DMD?

reply Jacob Carlborg <doob me.com> writes:
Is it possible to link a DLL compiled for MinGW with DMD?

-- 
/Jacob Carlborg
Aug 09 2012
next sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Thursday, 9 August 2012 at 13:43:18 UTC, Jacob Carlborg wrote:
 Is it possible to link a DLL compiled for MinGW with DMD?

Yeah, I've use dlls made in gcc with dmd. You need to run implib over the dll to get a .lib and then it works pretty easily. implib /s mydll.lib mydll.dll implib can be found in the basic utilities package at digital mars. http://www.digitalmars.com/download/freecompiler.html
Aug 09 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-08-09 15:48, Adam D. Ruppe wrote:

 Yeah, I've use dlls made in gcc with dmd. You need to run implib
 over the dll to get a .lib and then it works pretty easily.

 implib /s mydll.lib mydll.dll


 implib can be found in the basic utilities package at digital
 mars.

 http://www.digitalmars.com/download/freecompiler.html

Thanks, I'll give it a try. -- /Jacob Carlborg
Aug 09 2012
prev sibling next sibling parent "Dejan Lekic" <dejan.lekic gmail.com> writes:
On Thursday, 9 August 2012 at 13:43:18 UTC, Jacob Carlborg wrote:
 Is it possible to link a DLL compiled for MinGW with DMD?

Yes, it is possible. Long ago i have dealt with this almost on a daily basis (we used Borland C++ Builder on Windows in the former company I worked for). The easiest method is to use DEF files to create the import library. If you do not have it, you can use some tool that will analyse the DLL, make the DEF file for you, and then you modify it to your needs, and then create the import library for your target toolchain. This article explains everything you need to know: http://wyw.dcweb.cn/stdcall.htm Regards
Aug 09 2012
prev sibling next sibling parent "Dejan Lekic" <dejan.lekic gmail.com> writes:
On Thursday, 9 August 2012 at 13:48:14 UTC, Adam D. Ruppe wrote:
 On Thursday, 9 August 2012 at 13:43:18 UTC, Jacob Carlborg 
 wrote:
 Is it possible to link a DLL compiled for MinGW with DMD?

Yeah, I've use dlls made in gcc with dmd. You need to run implib over the dll to get a .lib and then it works pretty easily. implib /s mydll.lib mydll.dll implib can be found in the basic utilities package at digital mars. http://www.digitalmars.com/download/freecompiler.html

Yes, this works in most cases, but when it does not, then you have to use DEF files and modify/add symbols. It is not complicated, just time-consuming...
Aug 09 2012
prev sibling parent "dnewbie" <run3 myopera.com> writes:
There's an example:
http://my.opera.com/run3/blog/2012/01/24/mixing-c-and-d-on-windows-part-1
Aug 09 2012