|
-
March 21st, 2013, 03:04 PM
#3
Re: Extern C- Callinf Fortran from C++
Yes- I was able to get good information.
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
Can anyone please help?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|