This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: dll problem with gfortran under cygwin


How is it that intel fortran works ? does it automatically implement the
necessary windows call ?

--

Sincerely yours,
            Pasa Guglielmo


--------------

 guglielmo.pasa@bluewin.ch      ¦  tel. :  +41 (0)24 485 50 40 ¦

 mailing : Pasa Guglielmo       ¦  fax  :  +41 (0)24 485 50 44 ¦
           Rte des Cases 17A    ¦                              ¦ 
           CH-1890 St-Maurice   ¦  prof.: physicist,teacher    ¦
           (Switzerland)        ¦         & PhD Student        ¦ 


Ph.D.Student at:

Ecole Polytechnique Fédérale de Lausanne (EPFL)
Laboratory of Physics of Nanostructures
CH-1015 Lausanne, Switzerland
http://lpn.epfl.ch
-----Message d'origine-----
De?: THOMAS Paul Richard 169137 [mailto:prthomas@drfccad.cea.fr] 
Envoyé?: jeudi, 14. avril 2005 15:52
À?: 'guglielmo.pasa@bluewin.ch'
Cc?: 'fortran@gcc.gnu.org'
Objet?: dll problem with gfortran under cygwin

Gugliemo,

> Is it a problem with gfortran or with gcc ?

This is a problem of principle, rather than a problem with gfortran or gcc.
If you think about it, the protocol for sharing a keyboard between different
processes using the same dll is not straightforward. It is not even apparent
how stdout should be handled.

program dllmain
  external dlltest
  integer        ::  x, y
  y = 42
  call dlltest(x, y)
  print *, x, y
end program dllmain

subroutine dlltest(x, y)
  integer     ::   x, y
  x = y
!  write (*,*,iostat = ier) x, y
end subroutine dlltest

compiled and loaded as your example, works fine. The moment you uncomment
the write statement, the program bombs out.  Somewhat suprisingly IMHO, file
IO does not work.


You can go a bit further with a dll written in C:

#include <stdio.h>
int *
dlltest_ (int * x, int * y)
{
  static int retval = 0;
  *x = *y;
  printf (out, " x=%d   y=%d\n", *x, *y);
  return &retval;
} 

Works fine but any attempt at keyboard input through scanf causes a
segfault.

> What can I do to solve it ? (I need to use dlls) -- 

Use the Windows API in one way or another!  To give you an idea:

#include <stdio.h>
#include <windows.h>
int *dlltest_ (int * x, int * y)
{
  static int retval = 0;
  char out[100];
  *x = *y;
  sprintf (out, " x=%d   y=%d\n", *x, *y);
  MessageBox (NULL, out, "dlltest", MB_OK);
  return &retval;
}

Throws up a Windows message box.  The dialog boxes are a bit more
complicated but I have no doubt that a web search would produce plenty of
examples. I found, for another purpose completely,
http://www.winprog.org/tutorial/ to contain everything that I needed. 

If you do not want to venture into C programming, the best thing would be to
use one of the Widget toolboxes.  Dislin's (www.linmpi.mpg.de/dislin/ )work
fine with gfortran.  This also has the advantage that the program is
portable to Linux.

Good luck!

Paul T



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