Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Linking .lib library to fortran
How can I link a .lib library to a fortran program with cvf 6.6C?
Is there a way to view the contents of a .lib file (i.e. the names of the
subroutines and the kind of interface that is needed to call them).

Thanx!
Yiorgos



Report this thread to moderator Post Follow-up to this message
Old Post
Yiorgos Lykidis
12-23-04 02:03 PM


Re: Linking .lib library to fortran
Yiorgos Lykidis wrote:
>
> How can I link a .lib library to a fortran program with cvf 6.6C?
> Is there a way to view the contents of a .lib file (i.e. the names of the
> subroutines and the kind of interface that is needed to call them).
>
> Thanx!
> Yiorgos

In the settings for a project you can specify which libraries to add
(the Link tab).

Well, just looking into the library will probably reveal the names
of the subroutines, but there is no way as far as I know to determine
the interface. You will have to rely on documentation or ultimately
the source code.

Regards,

Arjen

Report this thread to moderator Post Follow-up to this message
Old Post
Arjen Markus
12-23-04 02:03 PM


Re: Linking .lib library to fortran
On Thu, 23 Dec 2004 12:53:48 +0200, "Yiorgos Lykidis" <abacus@freemail.gr>
wrote:

>How can I link a .lib library to a fortran program with cvf 6.6C?
>Is there a way to view the contents of a .lib file (i.e. the names of the
>subroutines and the kind of interface that is needed to call them).

You can view the names by starting a "Fortran Command Prompt" session and
using the command:

dumpbin -symbols mylib.lib

If the names end in @n, then it's a pretty good bet that the calling mechani
sm
is STDCALL and you can guess at the number of arguments.  But without the @n
,
you don't know for sure which mechanism (C or STDCALL) is used.  There is no
way to know what the datatypes or usage of the arguments are.


Steve Lionel
Software Products Division
Intel Corporation
Nashua, NH

User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://developer.intel.com/software/products/support/

Report this thread to moderator Post Follow-up to this message
Old Post
Steve Lionel
12-23-04 09:07 PM


Re: Linking .lib library to fortran
What is the difference between a C and an STDCALL? I simply want to call a
sbrtn which is located in the .lib file. Does this involve anything else
apart from inserting the .lib file in the project and having a CALL
SBRTN(a,b,c) statement?

Thank you very much for your help,
Yiorgos

"Steve Lionel" <Steve.Lionel@REMOVEintelME.com> wrote in message
 news:00qls016kb5gn2k9f6l2j95msun24ehaka@
4ax.com...
> On Thu, 23 Dec 2004 12:53:48 +0200, "Yiorgos Lykidis" <abacus@freemail.gr>
> wrote:
> 
>
> You can view the names by starting a "Fortran Command Prompt" session and
> using the command:
>
> dumpbin -symbols mylib.lib
>
> If the names end in @n, then it's a pretty good bet that the calling
mechanism
> is STDCALL and you can guess at the number of arguments.  But without the
@n,
> you don't know for sure which mechanism (C or STDCALL) is used.  There is
no
> way to know what the datatypes or usage of the arguments are.
>
>
> Steve Lionel
> Software Products Division
> Intel Corporation
> Nashua, NH
>
> User communities for Intel Software Development Products
>   http://softwareforums.intel.com/
> Intel Fortran Support
>   http://developer.intel.com/software/products/support/



Report this thread to moderator Post Follow-up to this message
Old Post
Yiorgos Lykidis
12-24-04 02:06 PM


Re: Linking .lib library to fortran
Yiorgos Lykidis wrote:
> What is the difference between a C and an STDCALL? I simply want to call a
> sbrtn which is located in the .lib file. Does this involve anything else
> apart from inserting the .lib file in the project and having a CALL
> SBRTN(a,b,c) statement?

The difference is how the stack is handled.  With the C mechanism, the
caller pops the stack after the call returns.  With STDCALL, the called
routine pops the stack at exit.  STDCALL is a trifle faster, and is the
convention MS uses for the Win32 API as well as calls from VB, etc., but
it also requires that the caller pass the exact number of arguments that
the called routine expects.

If you do not get this right, you will corrupt the stack due to it
either being popped twice or not at all.  In Intel (and Compaq)
compilers, you specify the mechanism with the !DEC$ ATTRIBUTES STDCALL
(or C) directive - see the Language Reference Manual, and the User's
Guide/Programmer's Guide chapter on mixed-language programming for more
information.

You also need to know whether the routine you're calling accepts
arguments by value or by reference.  As you can see, it is pretty much a
requirement that you KNOW what the called routine expects - there are
not enough clues in the .lib to tell you.

Note that CVF defaults to STDCALL while the Intel compilers default to C.

Steve Lionel
Intel Compiler Support

Report this thread to moderator Post Follow-up to this message
Old Post
Steve Lionel
12-24-04 08:57 PM


Re: Linking .lib library to fortran
I have managed to use the routine by setting the argument passing convention
for the External Procedures as "C, by reference" (CVF 6.6
Project-->Settings-->Fortran--->Ext. Proc.-->Argument Passing Convention).
i.e.:

call XYZ(a,b,c,d,e,f,g,h,i)

I'm trying to use a DEC command such as

!DEC$ATTRIBUTES C, REFERENCE:: XYZ

but it gives an unresolved external symbol _xyz.

What am I doing wrong?

Thanx,
Yiorgos

"Steve Lionel" <steve.lionel@NOintelSPAM.com> wrote in message
news:HaednSodDpAetVHcRVn-1Q@comcast.com...
> Yiorgos Lykidis wrote: 
a 
>
> The difference is how the stack is handled.  With the C mechanism, the
> caller pops the stack after the call returns.  With STDCALL, the called
> routine pops the stack at exit.  STDCALL is a trifle faster, and is the
> convention MS uses for the Win32 API as well as calls from VB, etc., but
> it also requires that the caller pass the exact number of arguments that
> the called routine expects.
>
> If you do not get this right, you will corrupt the stack due to it
> either being popped twice or not at all.  In Intel (and Compaq)
> compilers, you specify the mechanism with the !DEC$ ATTRIBUTES STDCALL
> (or C) directive - see the Language Reference Manual, and the User's
> Guide/Programmer's Guide chapter on mixed-language programming for more
> information.
>
> You also need to know whether the routine you're calling accepts
> arguments by value or by reference.  As you can see, it is pretty much a
> requirement that you KNOW what the called routine expects - there are
> not enough clues in the .lib to tell you.
>
> Note that CVF defaults to STDCALL while the Intel compilers default to C.
>
> Steve Lionel
> Intel Compiler Support







Report this thread to moderator Post Follow-up to this message
Old Post
Yiorgos Lykidis
12-27-04 01:55 PM


Re: Linking .lib library to fortran
Yiorgos Lykidis wrote:
>
> I have managed to use the routine by setting the argument passing conventi
on
> for the External Procedures as "C, by reference" (CVF 6.6
> Project-->Settings-->Fortran--->Ext. Proc.-->Argument Passing Convention).
> i.e.:
>
>   call XYZ(a,b,c,d,e,f,g,h,i)
>
> I'm trying to use a DEC command such as
>
> !DEC$ATTRIBUTES C, REFERENCE:: XYZ
>
> but it gives an unresolved external symbol _xyz.
>
> What am I doing wrong?
>
> Thanx,
> Yiorgos

Are you sure the routine has to be called that way?
What happens if you leave out the DEC statement?

Regards,

Arjen

Report this thread to moderator Post Follow-up to this message
Old Post
Arjen Markus
12-27-04 01:55 PM


Re: Linking .lib library to fortran
When the argument passing convention is set to "C, by reference" in the
project settings, the call works just fine without the DEC command. But
shouldn't this DEC command do the exact same thing?

thanx
Yiorgos

"Arjen Markus" <arjen.markus@wldelft.nl> wrote in message
news:41CFE3B4.E7867A79@wldelft.nl...
> Yiorgos Lykidis wrote: 
convention 
Convention). 
>
> Are you sure the routine has to be called that way?
> What happens if you leave out the DEC statement?
>
> Regards,
>
> Arjen



Report this thread to moderator Post Follow-up to this message
Old Post
Yiorgos Lykidis
12-27-04 08:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:58 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.