- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Much obliged, my program compiles and runs now!
Thanks!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page