View previous topic :: View next topic |
Author |
Message |
Jaap
Joined: 04 Jul 2016 Posts: 3
|
Posted: Tue Jul 05, 2016 9:02 am Post subject: Linking FTN95 code with Powerstation 4.0 dll |
|
|
I am trying to make an executable using FTN95 (v8.00.0)/SLINK and an old third party dll compiled with Powerstation 4.0. (32bit)
In the source code I have the interface statement and an external statement and also the dll is included in the Reference list in Plato.
However, the routine (SUBR1) in the .dll is not found when I compile the program: SLINK says:
Code: | WARNING the following symbols are missing:
SUBR1 H:\prog\X\lgotemp@.obj
|
An executable is produced but the following runtime error mentions the same:
Code: | Error 29: Call to missing routine
|
In the source code I have:
Code: | INTERFACE
SUBROUTINE SUBR1(r1, r2)
REAL * 4 r1,r2
END SUBROUTINE
END INTERFACE
EXTERNAL SUBR1
|
For clarity I have simplified the code, without removing essentials.
Jaap |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Tue Jul 05, 2016 10:59 am Post subject: |
|
|
I don't recall how Powerstation works but the DLL may use the STDCALL protocol for passing arguments.
If this is the case then you will need a STDCALL interface as described FTN95 in the help file under Win32 platform->Mixed language programming->Calling FTN95 from C/C++->Calling C/C++ from FTN95.
Admittedly you are calling Powerstation Fortran (not C/C++) from FTN95 but the interface may be right. The arguments will probably be passed by reference. Things get more complicated if, for example, you pass a character string because there will be additional hidden arguments and FTN95 will not known where to put them. |
|
Back to top |
|
|
Jaap
Joined: 04 Jul 2016 Posts: 3
|
Posted: Tue Jul 05, 2016 11:23 am Post subject: |
|
|
Given your last remark I might have simplified the example too much, as The actual subroutine is called with 22 variables including two strings and also arrays and 2-D tables. (Now simplified to include one 30char string)
When I change
into
I get compiler error message
Code: | *** SUBROUTINE SUBR1 has been called with too many arguents |
So changing code into:
Code: | STDCALL SUBR1 'subr1'(VAL,STRING(30),VAL) |
an executable is produced as expected, but that aborts runtime at the line the subroutine is called:
Code: | Access Violation
The instruction at address 1000c1d6 attempted to write to location ffffd8f1
1000c1d6 routine at address 1000C1D6 [+0000] |
Deleting INTERFACE definition gives same result. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Tue Jul 05, 2016 11:50 am Post subject: |
|
|
I don't think that I would even try to link FTN95 to a Powerstation Fortran DLL in this case. You would need to know how the arguments are passed (VAL or REF), where the hidden arguments are placed and what they do.
Do you have the source code for the DLL? |
|
Back to top |
|
|
Jaap
Joined: 04 Jul 2016 Posts: 3
|
Posted: Thu Jul 07, 2016 12:22 pm Post subject: |
|
|
Hi Paul,
Thank you for analyzing the dll specifics.
Your solution to change VAL into REF and add '//char(0)' to the string made my day.
Thanks! |
|
Back to top |
|
|
|