문제

I need following function (from C++ dll) available in C++/CLI

extern "C" _declspec(dllexport) void __stdcall DestroyInstance(CKeyManagerServerApp *ptr);

My try:

[DllImport("KeyManagerServer.dll", CallingConvention=CallingConvention::StdCall)]
void DestroyInstance(CKeyManagerServerApp IntPtr);

The C++/CLI wrapper is compiled with /clr and stdcall (C++ dll also with stdcall)!

I got following errors:

MKeyManagerInterface.obj : error LNK2028: unresolved token (0A000585) "extern "C" void __stdcall DestroyInstance(class CKeyManagerServerApp *)" (?DestroyInstance@@$$J14YGXPAVCKeyManagerServerApp@@@Z) referenced in function "private: __clrcall MKeyManagerInterface::ManagedKeyInterface::~ManagedKeyInterface(void)" (??1ManagedKeyInterface@MKeyManagerInterface@@$$FA$AAM@XZ)
1>MKeyManagerInterface.obj : error LNK2019: unresolved external symbol "extern "C" void __stdcall DestroyInstance(class CKeyManagerServerApp *)" (?DestroyInstance@@$$J14YGXPAVCKeyManagerServerApp@@@Z) referenced in function "private: __clrcall MKeyManagerInterface::ManagedKeyInterface::~ManagedKeyInterface(void)" (??1ManagedKeyInterface@MKeyManagerInterface@@$$FA$AAM@XZ)
1>..\Debug\Bin\KeyManagerInterfaceD.dll : fatal error LNK1120: 2 unresolved externals

How can I solve this linker errors?

Thx

도움이 되었습니까?

해결책

You shouldn't need to use P/Invoke from C++/CLI. You should be able to include the usual C/C++ header files that declare the imported function. Just make sure to link your C++/CLI assembly against the export library from the native-code DLL that exports the function in question.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top