Silverfrost Forums

Welcome to our forums

dll problem

10 Jan 2008 3:40 #2610

Hi, we would like to create a project containing a simple fortran exe and a simple fortran dll.

when we try to execute we have 'Error 29, Call to missing routine : _SUBSIMPLE@0 at 0x00401027'

the code is: (exe)

F_stdcall SubSimple call SubSimple() stop end

( dll ) SUBROUTINE SubSimple PRINT *,'Simple subroutine called' END SUBROUTINE

We also try with exportall switch, without success.

How can we solve? Have you some example of fortran exe calling fortran dll? thanks.

12 Jan 2008 12:13 #2618

Wild guess – try all lowercase subroutine name (or all upper).

12 Jan 2008 7:53 #2620

If you are compiling the DLL using FTN95 then you do not need F_STDCALL. Alternatively you must use F_STDCALL in both your DLL and executable.

FTN95 code is not case-sensitive. Only uppercase names are passed to the linker. This only becomes an issue if you are accessing a Fortran DLL from non-Fortran code.

14 Jan 2008 7:04 #2635

I try with lovercase and uppercase, with and without F_STANDARD.....

No way....

may my problem be in some project parameters?

have you some solution example (like 'visualcinteroperability' with fortran instead of C) ?

thanks

15 Jan 2008 7:18 #2637

Your sample looks OK if you take out the F_STDCALL line.

Your DLL must be in the same folder as your exe or alternatively it could be in a folder that is included in the PATH environment variable.

15 Jan 2008 5:28 #2646

may i post the zip file of my project?

Thanks

16 Jan 2008 7:44 #2648

We would need to make a charge for this service. You can send an email to Silverfrost to ask for details.

Here is a simple example that may help. Remember to keep the results in one folder.

File lib1.f90

subroutine sub1
print*,'Hello from sub1'
end

File main.f90

program main
call sub1
end

Building from a command line

ftn95 lib1 /link lib1.dll
ftn95 main /link /ref lib1.dll

Another way to build from a command line

ftn95 lib1
slink lib1.obj -dll -exportall
ftn95 main
slink main.obj lib1.dll

In both cases the executable is main.exe

17 Jan 2008 3:23 #2660

Thanks PaulLaidler

with your instructions and command line it works. But i need to understand some things....

why you link main.obj whith lib1.dll?

I think my problem is here.

Is there a way to indicate in the source ( and not at link time) where is my dll?

( in vb6 i add line like: Declare Function iajfltdll Lib 'pcroutdll.dll' (i4 As Long, dd As Single) As Integer )

Thanks

17 Jan 2008 5:39 #2661

The linker needs to know where the DLL is both for its own use and to embed this information in the executable.

There is a LIBRARY directive that you can write into the code but this only works when you use /LINK or /LGO on the FTN95 command line.

The recommended route is to create a project in either Plato3 or Visual Studio and then all of this information goes into the project data.

Please login to reply.