Silverfrost Forums

Welcome to our forums

Linking to third-party DLLs

1 Sep 2005 11:41 #308

I joined the forum a bit too late to see the beginning of the discussion of linking third-party DLLs to FTN 95. Can somebody send me a few lines of code to accomplish this?

Here is a sample of what I want to do -- a sample that is accepted by one Fortran 95 compiler: INTERFACE STDCALL FUNCTION Their_Function (my_int1, my_strngptr, my_int2) RESULT (my_i2r) !DIR$ ATTRIBUTES DLL_IMPORT :: Their_Function INTEGER4, VALUE :: my_int1 INTEGER4, VALUE :: my_strngptr INTEGER2, REFERENCE :: my_int2 INTEGER2 my_i2r END FUNCTION END INTERFACE

Here is the same thing, coded for a different compiler: INTERFACE TO INTEGER2 FUNCTION Their_Function (my_int1, my_strngptr, my_int2) !DEC$ ATTRIBUTES DLLIMPORT :: Their_Function INTEGER4 my_int1 [value] INTEGER4 my_strngptr [value] INTEGER2 my_int2 [reference] END INTERFACE

I am at a loss to figure out what Salford FTN 95 is looking for in an INTERFACE declaration. I have tried various combinations of the above, and everything gives error messages. Would someone please help with this?

If you wish, you could send a private message to me at harry.akers@mms.gov

1 Sep 2005 11:25 #310

Start by using /IMPORT_LIB <dll_name> on the FTN95 command line. You can do this from Plato by creating a project and creating a reference in the Project Explorer window. In this case you will also need to set the properties of reference to STDCALL.

If your call needs an interface (e.g. when using optional and/or key word arguments) then the relevant form in FTN95 is like this

INTERFACE F_STDCALL FUNCTION foo... ... END FUNCTION END INTERFACE

i.e. the keyword for the STDCALL attribribute is F_STDCALL.

Please login to reply.