I'm having trouble creating and calling a C dll using Visual C++ EE. The C file is really simple:
extern __declspec(dllexport) int retnum()
{
return 0;
}
In the project I have a header file with:
__declspec(dllimport) int retnum();
The actual project is in manage C++(it's a windows form). I included the header file at the top and call the function:
retnum();
but I'm getting some errors from the linker:
1>control.h(3) : warning C4272: 'retnum' : is marked __declspec(dllimport); must specify native calling convention when importing a function.
1>Linking...
1>Sample.obj : error LNK2028: unresolved token (0A00000C) "int __clrcall retnum(void)" (?retnum@@$$FYMHXZ) referenced in function "private: void __clrcall Sample::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@Sample@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Sample.obj : error LNK2019: unresolved external symbol "int __clrcall retnum(void)" (?retnum@@$$FYMHXZ) referenced in function "private: void __clrcall Sample::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@Sample@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
I haven't worked with dlls before, so I'm kind of lost. I havent specified were the dll is or what it's called anywhere in the main program, so I'm pretty sure that might be part of the problem, but I dont know how or were to do that.
Question
CentralDogma
I'm having trouble creating and calling a C dll using Visual C++ EE. The C file is really simple:
extern __declspec(dllexport) int retnum() { return 0; }In the project I have a header file with:
The actual project is in manage C++(it's a windows form). I included the header file at the top and call the function:
but I'm getting some errors from the linker:
I haven't worked with dlls before, so I'm kind of lost. I havent specified were the dll is or what it's called anywhere in the main program, so I'm pretty sure that might be part of the problem, but I dont know how or were to do that.
Link to comment
Share on other sites
4 answers to this question
Recommended Posts