I have Parallel Studio XE 2013 with Visual Studio 2013. .
- I start a new IVF Project (static Lbrary)
- In VS2013, I add a new win32 console application to the IVF Project
- I set the fortran function dependent to the main cpp
Please see below
//
#include "stdafx.h"
#include <iostream>
using namespace std;
extern "C"
{
void __cdecl FR1(int *a, int *b);
int __cdecl FF1(int *c);
}
int main()
{
int n = 10;
int nSq;
int nCube;
FR1(&n, &nSq);
cout << "The square is:"<< nSq << endl;
nCube = FF1(&n);
cout << "The cube is:"<< nCube << endl;
getchar();
return 0;
}
// fortran f90
subroutine FR1(N,M) !DEC$ ATTRIBUTES DLLEXPORT :: FR1 M = N*N return end integer function FF1(N) !DEC$ ATTRIBUTES DLLEXPORT :: FF1 FF1 = N*N*N return end
I am trying to call a fortran function f90 from C++, but i got two time the error message LNK2019
error LNK2019: unresolved external symbol referenced "_FR1" in function _main
error LNK2019: unresolved external symbol referenced "_FF1" in function _main
With Dumpbin /symbols I got the error message LINK: fatal error LNK1181 cannot open input file
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC> cd c:\visual studio 2013
\Projekt2\Fortfunc\Debug
c:\visual studio 2013\Projekt2\Fortfunc\Debug>dumpbin/symbols Fortfunc.dll
Microsoft (R) COFF/PE Dumper Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file Fortfunc.dll
LINK : fatal error LNK1181: Eingabedatei "Fortfunc.dll" kann nicht geöffnet werden.
Thanks in Advance