Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageYiorgos 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
Post Follow-up to this messageOn 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/
Post Follow-up to this messageWhat 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/
Post Follow-up to this messageYiorgos 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
Post Follow-up to this messageI 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
Post Follow-up to this messageYiorgos 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
Post Follow-up to this messageWhen 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
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.