Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [photran] How to build a Windows DLL from a fortran code with

Title: cordialement.txt
Le 01/05/2010 20:54, Keith Prussing a écrit :
I played with this a bit more today, and I'm not sure where the discrepancy is. To
try and see if it was that the library I made was too simple, I went and downloaded
the BLAS library source code and tried to build a DLL. I followed the steps I 
presented and everything compiled. I did not have to put any extra flags in any of
the BLAS source files. I then grabbed the test programs to check my build. Once I 
made sure that the compiler knew which library to use and where to find it, 
everything compiled smoothly. When I run the programs from the command line, I just
have to add the location of the DLL to my path and everything works fine. The only
catch is I can't successfully launch the executable from inside photran unless I 
just copy the DLL to the current directory.

  
First, thanks a lot for your help Keith.

The difference may come from the fact that I am using galileo in the Win64 version with gcc/gfortran 4.5.0 for Win64 ???
I have read somewhere in the web that  unlike Win32, Win64 uses standard C calling convention (hence -mrtd would not have to be used with Win64).

In fact, Keith is right: by simply using gfortran -O2 -c foo.f90 and then gfortran -shared -o foo.dll foo.o, the DLL *IS CREATED* and all the routines are inside (I was not looking at the right place in depends.exe from Dependency walker).
However, the visual basic main program (graphical interface for the fortran code) still does not find the relevant subroutine in foo.dll.

I finally discovered that it was (probably) because the names in the DLL were lowercase whereas, VisualBasic was waiting for names in uppercase.
By googling a bit, I saw that the possibility to put the names in the DLL uppercase was present in g77 but apparently dropped in gfortran...


PS: I have also tried using the new possibility of GCC 4.5.0 !GCC$ ATTRIBUTES DLLEXPORT.
However, during first compilation it gives errors such as "error: external linkage required for symbol 'foo_sub1' because of 'dllexport' attribute"

--
Cordialement,

Michel DEVEL

Back to the top