View previous topic :: View next topic |
Author |
Message |
cecio
Joined: 02 Sep 2007 Posts: 11
|
Posted: Thu Jan 10, 2008 4:40 pm Post subject: dll problem |
|
|
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. |
|
Back to top |
|
|
Keith Waters
Joined: 07 Aug 2007 Posts: 29 Location: London or Somerset, UK
|
Posted: Sat Jan 12, 2008 1:13 am Post subject: |
|
|
Wild guess – try all lowercase subroutine name (or all upper). |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Sat Jan 12, 2008 8:53 am Post subject: |
|
|
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. |
|
Back to top |
|
|
cecio
Joined: 02 Sep 2007 Posts: 11
|
Posted: Mon Jan 14, 2008 8:04 pm Post subject: Re: |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Jan 15, 2008 8:18 am Post subject: |
|
|
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. |
|
Back to top |
|
|
cecio
Joined: 02 Sep 2007 Posts: 11
|
Posted: Tue Jan 15, 2008 6:28 pm Post subject: Re: |
|
|
may i post the zip file of my project?
Thanks |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Wed Jan 16, 2008 8:44 am Post subject: |
|
|
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
Code: | subroutine sub1
print*,"Hello from sub1"
end |
File main.f90
Code: | program main
call sub1
end |
Building from a command line
Code: | ftn95 lib1 /link lib1.dll
ftn95 main /link /ref lib1.dll |
Another way to build from a command line
Code: | ftn95 lib1
slink lib1.obj -dll -exportall
ftn95 main
slink main.obj lib1.dll |
In both cases the executable is main.exe |
|
Back to top |
|
|
cecio
Joined: 02 Sep 2007 Posts: 11
|
Posted: Thu Jan 17, 2008 4:23 pm Post subject: Re: |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Thu Jan 17, 2008 6:39 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
|