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

Visual Studio 2005 C++ and Intel Fortran Compiling Errors

Roop
Beginner
610 Views

Hi, I am very new to Visual Studio and Intel Fortran, and fairly novice at both C++ and Fortran languages. I wanted to create a program in C++ that calls to a Fortran static library. I started simple, using examples I found from the internet. My C program looks like:

[cpp]#include "stdafx.h"
#include 
#include 
using namespace std;

extern "C"
   {
     void __cdecl FR1(int *,int *);
     int __cdecl FF1(int *);
   }

// ------------------------------------- Main Program

int main()
   {
     int n = 10, nSq, nCube;

     FR1(&n,&nSq);

 

     cout << "The square is:" << nSq << endl;

     nCube = FF1(&n);

     cout << "The Cube is:" << nCube << endl;

     return 0;
   }

[/cpp]

And my Fortran static library only contains one .F90 file that looks like this:

[fortran]SUBROUTINE FR1(N,M)
   M=N*N
   RETURN
   END

INTEGER FUNCTION FF1(N)
   FF1=N*N*N
   RETURN
   END[/fortran]

I made these in two seperate solution files. In my C, I set Properties > Linker > Additional Library Directories to the correct path that my fortran .lib is in. I also set Linker > Input > Additional Dependencies > test.lib. When I go to build the code this way, I get the following error:

LINK : fatal error LNK1104: cannot open file 'ifconsol.lib'

I looked up this file and found it in the Visual Studio folder, but I'm not sure why my program is asking for it. When I put the fortran project in with my c++ solution and try to build it without linking at all, I recieve this error:

Driver.obj : error LNK2019: unresolved external symbol _FF1 referenced in function _main

Driver.obj : error LNK2019: unresolved external symbol _FR1 referenced in function _main

I've done a lot of looking at other people's problems, but changes I make seem to just create different errors. I'm still very new to all of this and I would appreciate anyone's thoughts on the matter. Thanks in advance!

Roop

0 Kudos
1 Solution
3 Replies
Les_Neilson
Valued Contributor II
610 Views

For the ifconsol.lib problem you need to do the following
Tools -> Options -> Projects and Solutions -> VC++ Directories

In the rhs of the panel from the "Show directories for" drop down control select "Library Files"

Add $(IfortInstallDir)\lib\ia32 (for the Win32 platform)
(or the path appropriate for the 64-bit platform if you need it)

Les

0 Kudos
Roop
Beginner
610 Views

Much obliged, my program compiles and runs now!

Thanks!

0 Kudos
Reply