[Dev-C++] FW: Trouble linking FORTRAN DLL with C++ application (undefined reference)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Steve K. <dr_...@ho...> - 2004-01-28 21:17:18
|
Is it possible for a Dev-CPP application to link a .lib file produced by MSVC++ or Digital Visual Fortran? If not, could Dev-CPP link with DLL created by g77? I sent a note to comp.lang.fortran (see bottom of message) and got the suggestion below by Jugoslav Dujic to check whether Dev-CPP and DVF could be made binary-compatible. Thanks for your help! - Steve Kramer From Jugoslav: __________________________________________ It seems you followed a correct procedure... for linking with Visual C++. I suspect the problem is that you're using Dev-C++, and I don't know if it's link-compatible with MSVC++/CVF. Based on the info from web site you provided, it seems not (it says that its compiler is Mingw port of gcc). You'd be probably better off asking this in a Devcpp/mingw/gcc specific group. The issue is the same as how to call a dll written in VC++ from that environment (as CVF .dlls and .libs are the same as VC++ looking from outside). -- Jugoslav ___________________________________________________ ----Original Message Follows---- From: pos...@go... Reply-To: pos...@go... To: dr_...@ho... Subject: Trouble linking FORTRAN DLL with C++ application (undefined reference) Date: Tue, 27 Jan 2004 17:16:07 -0800 From: dr_...@ho... (Steve Kramer) Newsgroups: comp.lang.fortran Subject: Trouble linking FORTRAN DLL with C++ application (undefined reference) NNTP-Posting-Host: 24.206.121.222 Message-ID: <538...@po...> 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://groups.google.com/groups?selm=9prq7m%24kef4q%241%40ID-106075.news.dfncis.de&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 _________________________________________________________________ Find high-speed net deals comparison-shop your local providers here. https://broadband.msn.com |