This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: g77/dllwrap: getarg returns nothing -- more info, please help

It has been pretty quiet on this one.  I've reaearched a little further 
and here's how g77's getarg accesses argc and argv.  I need help
how to massage this into the dll spec:

A Fortran program calls a main that is defined in libF77.  This main looks 
something like this:

int f__argc;
char** f__argv;

int main( int argc, char **argv ) {
   f__argc = argc;
   f__argv = argv;
   /* call actual Fortran main program */

And getarg in libF77 does this:

extern int f__argc;
extern char** f__argv;
getarg_(int *n, char *s, long l ) {
   s = f__argv[*n];


Now if the subroutine geti (see below) is in a dll it 
apparantly accesses a different f__argv than the one
that got linked into program test, which is outside the 

How can the dll be made so it accesses the same
f__argv than the calling main program?  Can it be
done or has libF77 to be changed?

Hope the above makes sense and I haven't 
oversimplified things.

Please help.


------- Start of forwarded message -------
From: Michael Lemke <>
Subject: g77/dllwrap: getarg returns nothing
Date: 4/14/01 19:45:13

I am trying for the first time to build a dll and I've stumbled across this:
g77 getarg returns nothing if called from a dll.  This is what I did:

Test> cat test.f
        program test
        implicit none

        character x*132
        integer i

        call geti( x, i )


Test> cat geti.f
        subroutine geti( image, len_image )
        implicit none

        character*(*) image
        integer len_image

        character*20 prg_name

        call getarg( 1, prg_name )
        print *, 'getarg''ed: |'//prg_name//'|'


Test> g77 -c test.f
Test> g77 -c geti.f
Test> g77 test.o geti.o
Test> ./a blah
 getarg'ed: |blah                |

Ok, that works.  Here's the problem:

Test> dllwrap --driver-name g77 --implib libgeti.a  --export-all -o geti.dll geti.o
dllwrap: no export definition file provided
dllwrap: creating one, but that may not be what you want
Test> g77 test.o -L . -lgeti
Test> ./a blah
 getarg'ed: |                    |

Now there is nothing between |...|

Is there anything special that has to be done for the dll?  Some magic
initialization or declaration?

I'd really like this to work.  I couldn't find anything in the FAQ, documentation
etc.  The only impression I got is that dll's are a rather complicated beast.

-------- End of forwarded message --------

Want to unsubscribe from this list?
Check out:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]