Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29280 Discussions

C++ Calling Fortran - Studio 2005 and Intel 9.1

mattintelnetfort
Beginner
885 Views
I had Studio 2003 projects accessing fortran DLL subroutines built with Intel 9.0. Now I've upgraded to Studio 2005 and Intel 9.1 andI'm getting link errors whenever I try to call a fortran subroutine from C++. Any thoughts? I've read the install and release notes and see no mention. This worked before the upgrade. Do I need to remigrate the fortran projects somehow?
0 Kudos
9 Replies
Nick2
New Contributor I
885 Views
What do the errors say?
0 Kudos
mattintelnetfort
Beginner
885 Views

I'm getting unresolved external errors. I verified within Studio that I reference the Fortran DLL from the C++ DLL as a dependency within the solution. Again this worked before the Visual Studio and IVF upgrades (2003->2005 and 9.0->9.1 respectively). Any help would be appreciated.

Example Error:

error LNK2019: unresolved external symbol _FORTRANSUBROUTINENAME@16 referenced in function "public: long __thiscall CMyCPLUSPLUSCLass::MyMethod(long *,double * const,double * const)" (?MyMethod@CMyCPLUSPLUSCLass@@QAEJPAJQAN1@Z)

0 Kudos
Jugoslav_Dujic
Valued Contributor II
885 Views
The linker message says that FortranSubroutineName is declared in C++ as __stdcall. The IVF default has always been __cdecl, so the dll has either been built with /iface:CVF or with explicit !DEC$ATTRIBUTES STDCALL, ALIAS:. Check the actual dll exports with Dependency Walker (depends.exe) or dumpbin.exe.
0 Kudos
Steven_L_Intel1
Employee
885 Views
I've heard recently, though I haven't seen it myself yet, that a mixed C/Fortran VS2005 solution with a Fortran library may not include the Fortran library even though it is a dependent project. You can try adding the Fortran .lib explicitly to the C++ project if this is happening to you.
0 Kudos
mattintelnetfort
Beginner
885 Views
Yes with an explicit dll link reference, I can link - the project dependencies within the Visual Studio 2005 solution does not seem to work as it did in previous releases when dealing with C++Dlls referencing Fortran DLLs.
Thanks for your help!
0 Kudos
ivangpetrovski
Beginner
885 Views
I also had the same problem with linking Fortran in 2005. Adding the lib worked for me as well.
Thanks
0 Kudos
Steven_L_Intel1
Employee
885 Views
I can now confirm - Microsoft changed VS2005 so that C++ projects do not ask other non-C++ projects about build outputs, even though MS provides a supported interface for doing so (that we implement and which worked in VS2002-2003.) So if you have a C++ main, you'll have to manually add the .lib of the Fortran project to the C++ project.
0 Kudos
dbruceg
Beginner
885 Views
I've just converted to VF9.1. May I glean from the above discussion that I should not have any problems running a particular Fortran DLL under both Fortran console apps and Fortran Windows apps?
Bruce
0 Kudos
Steven_L_Intel1
Employee
885 Views
I can't think of any reason you should have an issue with that.
0 Kudos
Reply