Trouble linking FORTRAN DLL with C++ application (undefined reference)
From: Steve Kramer (dr_steve_kramer_at_hotmail.com)
Date: 01/28/04
- Next message: TimC: "Re: making directories and subdirectories"
- Previous message: Duane Bozarth: "Re: Help from fellow Fortran Users"
- Next in thread: Jugoslav Dujic: "Re: Trouble linking FORTRAN DLL with C++ application (undefined reference)"
- Reply: Jugoslav Dujic: "Re: Trouble linking FORTRAN DLL with C++ application (undefined reference)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Jan 2004 17:16:06 -0800
I created a FORTRAN DLL with Digital Visual Fortran 6.0 and have been
able to access that DLL successfully from a calling application in
FORTRAN.
I'm now trying to call the same FORTRAN DLL from C++ and am having
trouble with the getting the calling conventions right. I have
reviewed some relevant articles in comp.lang.fortran and in the Intel
developer forum, including these:
http://groups.google.com/groups?selm=68rm8a%249ej%40usenet.pa.dec.com&oe=UTF-8&output=gplain
http://softwareforums.intel.com/ids/board/message?board.id=15&message.id=739
Based on those and other articles, here's how I set things up.
(1) FORTRAN DLL source code:
Subroutine FORTRANINIT(int1,int2)
!
!
!DEC$ ATTRIBUTES DLLEXPORT::FORTRANINIT
!DEC$ ATTRIBUTES ALIAS : "_FORTRANINIT@8" :: FORTRANINIT
INTEGER*4 int1, int2
(2) Calling C++ program source code:
extern "C"
{
__declspec(dllimport) void __stdcall FORTRANINIT(int* int1,
int* int2);
}
void main()
{
int int1, int2;
<snip>
FORTRANINIT(&int1, &int1);
}
(3) Building/compiling:
(a) I built FORTRANINIT.dll first (in DVF 6.0) and copied it to the
C++ application's directory.
(b) I added the FORTRANINIT.lib file to the C++ project in Bloodshed
Dev-C++ 4.0 (from www.bloodshed.net/devcpp.html) and compiled the
calling C++ application.
(c) There were no compilation errors, but there was a linker error:
undefined reference to `_imp__FORTRANINIT@8'
Any ideas as to what I'm missing here? I would like to be able to
call the same FORTRAN DLL from FORTRAN and C++. I have tried
omitting both the FORTRAN ALIAS as well as the __declspec(dllimport)
in C++ without any luck.
Thanks in advance for the help!
- Steve Kramer
- Next message: TimC: "Re: making directories and subdirectories"
- Previous message: Duane Bozarth: "Re: Help from fellow Fortran Users"
- Next in thread: Jugoslav Dujic: "Re: Trouble linking FORTRAN DLL with C++ application (undefined reference)"
- Reply: Jugoslav Dujic: "Re: Trouble linking FORTRAN DLL with C++ application (undefined reference)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|