- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use CFV 6.6c. In order for a third-party application to access an application of mine written in FORTRAN, I must supply it in the form of a DLL containing a subroutine with an exported lower case name 'usersub'. That is the routine that the third-party app. looks for (I think it is C-based).The standard compiler directive DLLEXPORT produces a DLL with 2 exports for a subroutine named USERSUB. These are USERSUB and_USERSUB@8 (The subroutine takes two arguments). When building the DLL, I have to include a Third-party .OBJ containing routines that it requires to be present, one of whose names (cvsetupprocedure) is exported using '/export: cvsetupprocedure' added to the project's linker step. I would like to know two things
1) How can I achieve a lower-case exported name 'usersub' using compiler directives? (I achieved this by using /export:usersub=_USERSUB@8 as a linker stage addition, but am not sure why it worked!)
2) Why does the listing produced by DUMPBIN /SYMBOLS carried out seperately on the Dynamic-link library's .DLL and .LIB files produce names which sometimes differ by a leading underscore? I include sample listing below.(p.s., for some reason, when I type_USERSUB@8 itis almost always automatically underlined in the above text, when it should only have a leading underscore!)
C:F90DF
ewbeamsUSERSUBRelease>DUMPBIN USERSUB.lib /EXPORTS
Microsoft COFF Binary File Dumper Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Microsoft COFF Binary File Dumper Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Dump of file USERSUB.lib
File Type: LIBRARY
Exports
ordinal name
Summary
C6 .debug$S
14 .idata$2
14 .idata$3
4 .idata$4
4 .idata$5
C .idata$6
14 .idata$2
14 .idata$3
4 .idata$4
4 .idata$5
C .idata$6
C:F90DF
ewbeamsUSERSUBRelease>DUMPBIN USERSUB.DLL /EXPORTS
Microsoft COFF Binary File Dumper Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Microsoft COFF Binary File Dumper Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Dump of file USERSUB.DLL
File Type: DLL
Section contains the following exports for usersub.dll
0 characteristics
43D608CF time date stamp Tue Jan 24 11:00:31 2006
0.00 version
1 ordinal base
3 number of functions
3 number of names
43D608CF time date stamp Tue Jan 24 11:00:31 2006
0.00 version
1 ordinal base
3 number of functions
3 number of names
ordinal hint RVA name
Summary
1000 .data
1000 .rdata
1000 .reloc
1000 .text
1000 .trace
1000 .rdata
1000 .reloc
1000 .text
1000 .trace
C:F90DF
ewbeamsUSERSUBRelease>
Message Edited by anthonyrichards on 01-24-200604:28 AM
Message Edited by anthonyrichards on 01-24-2006 04:29 AM
Message Edited by anthonyrichards on 01-24-2006 04:30 AM
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
!DEC$ ATTRIBUTES DLLEXPORT, ALIAS:"usersub" :: usersub
The Microsoft tools sometimes hide the leading underscore. I agree it is frustrating.
The Microsoft tools sometimes hide the leading underscore. I agree it is frustrating.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Steve. After finally getting my application to start with a call to my DLL containing the exported symbol 'usersub' from the third-party app., I found that when I finally exited from my application by returning from the 'usersub' routine, the third party app. crashed with an access error. After various attempts at 'voodoo' to solve the problem(!!), Igot the feeling that this might be due to C/Fortran stack handling problems, so I played around with !DEC$ directives until I hit on one that worked and the third party app. stopped crashing on return from my app. Here is what I found worked:
!DEC$ ATTRIBUTES REFERENCE, C :: USERSUB
!DEC$ ATTRIBUTES DLLEXPORT :: USERSUB
!DEC$ ATTRIBUTES DLLEXPORT :: USERSUB
Abonus is that this appears to automatically produce a lower-case exported name in the DLL that isproduced.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yup - if the calling application expects the C calling interface, your solution is good. I recommend adding the alias anyway as CVF is supposed to be adding an underscore. I've seen some situations where it doesn't.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page