www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Link against MinGW libraries

reply "Kai Meyer" <kai gnukai.com> writes:
There's got to be a way to link against libraries generated by 
MinGW, right? I'm using CMake to create a very simple 1 method 
library. If I tell D to link against the .lib (simple ar 
archive), it complains that it's an invalid library. If I tell D 
to link against the .dll, it complains that there is no .lib.

I seem to remember thinking that Microsoft tools create a .dll 
and a .lib for development libraries, and you link against the 
.lib but run against the .dll. I don't know how to make MinGW (or 
cmake for that matter) generate both the .dll and .lib. I seem to 
remember that other projects I've built with the Visual Studio 
compiler, I get .lib and .dll files for my shared libraries, and 
those seem to work.

Any help would be appreciated.
Aug 22 2012
next sibling parent "Maxim Fomin" <maxim maxim-fomin.ru> writes:
On Wednesday, 22 August 2012 at 14:56:40 UTC, Kai Meyer wrote:
 There's got to be a way to link against libraries generated by 
 MinGW, right? I'm using CMake to create a very simple 1 method 
 library. If I tell D to link against the .lib (simple ar 
 archive), it complains that it's an invalid library. If I tell 
 D to link against the .dll, it complains that there is no .lib.

 I seem to remember thinking that Microsoft tools create a .dll 
 and a .lib for development libraries, and you link against the 
 .lib but run against the .dll. I don't know how to make MinGW 
 (or cmake for that matter) generate both the .dll and .lib. I 
 seem to remember that other projects I've built with the Visual 
 Studio compiler, I get .lib and .dll files for my shared 
 libraries, and those seem to work.

 Any help would be appreciated.
Which D compiler are you using?
Aug 22 2012
prev sibling next sibling parent Mike Parker <aldacron gmail.com> writes:
On 8/22/2012 11:56 PM, Kai Meyer wrote:
 There's got to be a way to link against libraries generated by MinGW,
 right? I'm using CMake to create a very simple 1 method library. If I
 tell D to link against the .lib (simple ar archive), it complains that
 it's an invalid library. If I tell D to link against the .dll, it
 complains that there is no .lib.

 I seem to remember thinking that Microsoft tools create a .dll and a
 .lib for development libraries, and you link against the .lib but run
 against the .dll. I don't know how to make MinGW (or cmake for that
 matter) generate both the .dll and .lib. I seem to remember that other
 projects I've built with the Visual Studio compiler, I get .lib and .dll
 files for my shared libraries, and those seem to work.

 Any help would be appreciated.
The issue is the object file format that the MinGW toolchain uses. It's different from that used by the DMD linker (assuming you are using DMD). What you should do here is download the basic utilities package from the Digital Mars site [1] and use the implib tool on your DLL. This will create a link library in a format the DMD linker understands. Link with it and you should be able to use your DLL. [1] http://www.digitalmars.com/download/freecompiler.html
Aug 22 2012
prev sibling next sibling parent "Kagamin" <spam here.lot> writes:
If I remember it correctly, you should write a .def file and 
compile it with dlltool or something like that. It will create 
the import library.
Aug 24 2012
prev sibling parent "Kagamin" <spam here.lot> writes:
There was also a switch for gcc or ld to generate an import 
library.
Aug 24 2012