For Programmers: Free Programming Magazines  


Home > Archive > Fortran > November 2004 > g95 - how to build a DLL









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author g95 - how to build a DLL
Gustav Ivanovic

2004-11-25, 8:56 pm

How do you build DLLs with g95 ?
Andy Vaught

2004-11-26, 4:09 pm

On 25 Nov 2004, Gustav Ivanovic wrote:

> How do you build DLLs with g95 ?
>


DLLs are build by running the microsoft linker with special options.
It may be able to link object files generated by g95 into an object file.
I don't know if it will or not.

Andy


E P Chandler

2004-11-26, 4:09 pm

gustav_ivanovic@yahoo.com (Gustav Ivanovic) wrote in message news:<c4855309.0411251239.13229afe@posting.google.com>...
> How do you build DLLs with g95 ?


Here's a procedure that worked for me using Cygwin and gfortran
instead of g95. In order to create a DLL callable from Visual Basic or
VBA (Word, Excel) it is necessary to create a MinGW dll but using
Cygwin tools. Apparently calls to the Cygwin dlls cause the program to
hang.

install gfortran in /home/irun.... then from a bash shell prompt:

gfortran -o foo.dll -s -shared -mrtd -mno-cygwin foo.f95

-o sets the output file to foo.dll
-s strips debug information
-shared creates a dll
-mrtd sets the calling convention to stdcall
-mno-cygwin builds a MinGW type executable

note that the subroutine name is decorated to foo_.

in order to get this to complete, you need to:

1. move f951.exe up the directory tree to /home/irun/bin
2. move missing .a files & missing .o files from /lib/mingw to
/home/irun/lib
3. move the right libgcc.a into /home/irun/lib

foo.f95 is:

subroutine foo(i)
integer i
i=i+1
return
end

see some of my previous posts on creating dlls for VB with g77 for
details on suitable Word documents as test programs.

This probably would work with g95 instead of gfortran if you can
install it properly and put the needed MinGW components in the proper
places. (Sorry, I gave up after installing g95 and getting it to
create Cygwin based executables.)
Charles Russell

2004-11-26, 9:10 pm


"Gustav Ivanovic" wrote

>How do you build DLLs with g95 ?


See also:
http://sources.redhat.com/ml/cygwin...1/msg00106.html


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com