Call dll problem
-
Hi, I have created a test dll in Fortran that squares an input number. Then I'm trying to call this dll from C++.NET using the following bit of code:
#include using namespace std; extern "C" __declspec(dllimport)double square(double X); int main(int argc, char* argv[]) { double a=4; double asq = square(a); cout << a << " " << asq << endl; return 0; } `I get the following error: HelloWorld error LNK2019: unresolved external symbol __imp__square referenced in function _main I've added MyDll.lib as a reference from the Fortran code but no success. (I'm not able to add MyDll.dll however, is this normal?) Any ideas please? Kash`
-
Hi, I have created a test dll in Fortran that squares an input number. Then I'm trying to call this dll from C++.NET using the following bit of code:
#include using namespace std; extern "C" __declspec(dllimport)double square(double X); int main(int argc, char* argv[]) { double a=4; double asq = square(a); cout << a << " " << asq << endl; return 0; } `I get the following error: HelloWorld error LNK2019: unresolved external symbol __imp__square referenced in function _main I've added MyDll.lib as a reference from the Fortran code but no success. (I'm not able to add MyDll.dll however, is this normal?) Any ideas please? Kash`
In the C++ .NET Framework you don't import functions from a DLL like you do in Win32; the syntax is different. The correct method is to use the DllImport attribute, which is located in: System::Runtime::InteropServices. Using the DllImport Attribute[^]