For Programmers: Free Programming Magazines  


Home > Archive > Fortran > February 2005 > Call exported subroutine within DLL









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Call exported subroutine within DLL
Gib Bogle

2005-02-23, 8:58 pm

(Using DVF 6.6) I have code that creates a DLL that is made available to
a Delphi program. The code below shows how a subroutine is exported.
Now I want to call this subroutine from within the DLL itself, but when
I do this I get a linker error:
"unresolved external symbol _SHARE_WIND_DATA@24"

What do I need to do to make this subroutine available within the DLL?

Thanks
Gib

subroutine share_wind_data(nw,ws,wf,td,tf,wc)
!DEC$ ATTRIBUTES REFERENCE :: nw,ws,wf,td,tf,wc
!DEC$ ATTRIBUTES STDCALL, DLLEXPORT :: share_wind_data
!DEC$ ATTRIBUTES ALIAS : "_share_wind_data" :: share_wind_data
Jan Vorbrüggen

2005-02-24, 8:58 am

Look up the various calling sequences supported by Microsoft and CVF.
It's only one of them that decorates the name with the length of the
argument list, and it might be that the one you are exporting from the
DLL uses the other convention - or your alias statement is wrong, and
thus the real symbol does not get decoratd with the underline. DUMPBIN
on the DLL should be your friend.

Jan
Colin Watters

2005-02-24, 8:58 pm

Since you have used the ALIAS attribute, your subroutine is only available
by the alias'd name, viz. "_share_wind_data". You won't find it with a
normal CALL statement coz Fortran expects externals to be in UPPERCASE and
(in the case of cvf) have stack-size "@" decoration.

Easiest fix is to copy the ALIAS directive in the calling code, exactly as
it is in the subroutine... eg:

call share_wind_data(a,b,c,d,e,f)
!dec$ attributes alias : "_share_wind_data" :: share_wind_data

--
Qolin

Email: my qname at domain
Domain: qomputing dot demon dot co dot uk
"Gib Bogle" <g.bogle@auckland.no.spam.ac.nz> wrote in message
news:421d01e7$1@news.auckland.ac.nz...
> (Using DVF 6.6) I have code that creates a DLL that is made available to
> a Delphi program. The code below shows how a subroutine is exported.
> Now I want to call this subroutine from within the DLL itself, but when
> I do this I get a linker error:
> "unresolved external symbol _SHARE_WIND_DATA@24"
>
> What do I need to do to make this subroutine available within the DLL?
>
> Thanks
> Gib
>
> subroutine share_wind_data(nw,ws,wf,td,tf,wc)
> !DEC$ ATTRIBUTES REFERENCE :: nw,ws,wf,td,tf,wc
> !DEC$ ATTRIBUTES STDCALL, DLLEXPORT :: share_wind_data
> !DEC$ ATTRIBUTES ALIAS : "_share_wind_data" :: share_wind_data



Gib Bogle

2005-02-27, 3:58 am

Thanks Colin. I suspected that ALIAS was the key, but I didn't know
exactly how to tell the calling code about it.

Gib

Colin Watters wrote:

> Since you have used the ALIAS attribute, your subroutine is only available
> by the alias'd name, viz. "_share_wind_data". You won't find it with a
> normal CALL statement coz Fortran expects externals to be in UPPERCASE and
> (in the case of cvf) have stack-size "@" decoration.
>
> Easiest fix is to copy the ALIAS directive in the calling code, exactly as
> it is in the subroutine... eg:
>
> call share_wind_data(a,b,c,d,e,f)
> !dec$ attributes alias : "_share_wind_data" :: share_wind_data
>
> --
> Qolin
>
> Email: my qname at domain
> Domain: qomputing dot demon dot co dot uk
> "Gib Bogle" <g.bogle@auckland.no.spam.ac.nz> wrote in message
> news:421d01e7$1@news.auckland.ac.nz...
>
>
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com