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

Mixed Language Programming Visual C/Intel FORTRAN

jimseal
Beginner
558 Views
While I've seen similar postings and tried various things based on them, I still can't successfully link a static library compiled in Intel FORTRAN v 9.0 and MS Visual Studio.NET 2003. I have some legacy code that I could compile before, but was recently upgraded to the above setup and can't link. I wrote a simple test scenario since my legacy code didn't work, and that doesn't link either. Here is the test code:
FORTRAN Static Library:
subroutine Lib1
use IFPORT
character*40 libname
CALL GETENV ('my_env',libname)
TYPE * , "The env variable is:", libname
end subroutine Lib1
Visual C++ Console Application:
#include
#include
extern void Lib1(void)
int main (void)
{
printf("In the C code ");
Lib1();
printf("Back from the FORTRAN call ");
return 0;
}
I have included the static library from above, libifcore.lib, and ifconsol.lib and the paths to them. I have tried every variation of calling conventions in both components, compile as straight C (vs. C++), etc., but still get unresolved external symbols:
_GETENV
_for_write_seq_lis
_for_write_seq_lis_xmit
Even if I take out the call to GETENV, I still get the other 2 errors, which are obviously some internal routines being called without me doing it explicitly. It could be something as simple as needing to include additional library dependencies, but I can't find any documentation on which libraries contain what. Any ideas?
Thanks.
0 Kudos
2 Replies
Steven_L_Intel1
Employee
558 Views
In your Fortran project properties, go to the Libraries page and set "Disable default library search rules" to "No" and rebuild. The default for Fortran static library projects is "Yes" here, which seemed reasonable back in the CVF days when static libraries tended to be used more by other Fortran projects, but in the brave new world of VS.NET, the more common use is mixed-language apps and this is no longer appropriate. I have a proposal in to change the default.

Also, make sure that the path to the Intel Fortran IA32LIB folder is included in your Tools..Options..Projects..VC++ Directories list for Library files.
0 Kudos
jimseal
Beginner
558 Views

Hey thanks! You just saved me from pulling the rest of my hair out. I had set the default library search to "no" before, but your second suggestion is what did it. For some reason I had selected "EM64TLib" instead of "IA32Lib". The sample compiles fine now.Now back to the legacy code...

Jim

0 Kudos
Reply