Advice on linking with Fortran?

John Reimer terminal.node at gmail.com
Fri Dec 8 17:12:05 PST 2006


On Fri, 08 Dec 2006 12:08:08 -0800, Bill Baxter <wbaxter at gmail.com> wrote:

> I'd like to link with some Fortran math libs on Windows, but there seems  
> to be a problem in that there isn't a "dmf" or other Fortran compiler  
> that spits out dmd-compatible object files.
>
> coff2omf would work I suppose if I didn't mind shelling out $15.


coff2omf is not a reliable conversion utility... since it seems that the  
coff format is not consistent across different versions of MS tools (and  
other compiler vendors, for that matter).  I don't think it works most of  
the time (not from my many attempts a couple years ago, at least).   
Relying on coff2omf becomes more discouraging than anyting else.


> I have managed to get something working, but the process is a bit  
> convoluted.  MinGW can be coaxed to create a dll using a crazy command  
> line like
>
> gcc -mno-cygwin -shared -o blaslapack.dll  
> -Wl,--out-implib=blaslapack.lib -Wl,--export-all-symbols  
> -Wl,--allow-multiple-definition -Wl,--enable-auto-import  
> -Wl,--whole-archive liblapack.a libf77blas.a libcblas.a  
> -Wl,--no-whole-archive libatlas.a -lg2c
>
> Then you can use implib on the result like:
>     implib /system blaslapack.lib blaslapack.dll
>
> To get something which can be used to link with DMD.
>
> But I'd rather not use a DLL for this since BLAS/LAPACK are libraries  
> (it comes to 11MB) with tons of things I don't really need.  I probably  
> only need a few K of what's in that DLL.  Static linking would make much  
> more sense.


Can you cut down the library to a minimum of required functions and then  
make a dll?  Perhaps that is excessively complicated if the library  
coupling is extensive.

-JJR




More information about the Digitalmars-d mailing list