Have you tried google 'calling fortran from c'? I get a lot of hits.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
I tried a small program which worked well. It was a simple one like this:
C++ code
Code:
#include <iostream>
extern "C"
{
int ffunc(int*, int*);
}
int main()
{
int n1 = 1;
int n2 = 2;
std::cout << "Calling from C++ to Fortran, arguments: " << n1 << ", " << n2 << '\n';
int r = ffunc(&n1, &n2);
std::cout << "THe return value from fortran was " << r << '\n';
}
FORTRAN
Code:
function ffunc(n1,n2)
integer ffunc
integer n1,n2
ffunc = n1+n2
return
end
Now, I have a template created by a wizard . This template eseentially contains C++ source to guide you in the construction of my Block application dialog. The generation of your dialog file (.dlx extension) is the first step towards dialog construction within the external software I'm using.
Here, in teh template, I have added the code in green
void calculator:ialogShown_cb()
{
try
{
//---- Enter your callback code here -----
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
calculator::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:ialogTypeError, ex.what());
}
}
extern "C"
{
//int ffunc(int,int);
int ffunc(int*, int*);
}
It throws the follwoign error while compiling indicate that there is no function found (the funtion of FORTRAN). I have fefined the FORTRAN library through Linker->Geneeral->Addnl library directories
Error 5 error LNK2019: unresolved external symbol ffunc referenced in function "public: int __cdecl calculator::apply_cb(void)" (?apply_cb@calculator@@QEAAHXZ) calculator.obj calculator
Error 5 error LNK2019: unresolved external symbol ffunc referenced in function "public: int __cdecl calculator::apply_cb(void)" (?apply_cb@calculator@@QEAAHXZ) calculator.obj calculator
This error message doesn't reference your Fortran function at all, unless I'm mistaken. So I suspect the actual problem is unrelated to the Fortran aspect, at least for the most part.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Have you added the library to Linker/Input/Additional Dependencies? Linker/General/Additional Library Directories should only have the path.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
No that should be enough. Sure strip the project of all generated files, zip it and post it.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
Hm. For some reason downloading of those zips are blocked by the SmartScreen Filter.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.