![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I want to call a (static) native function "DeleteInstance". These methods looks like in the header-file: static void DeleteInstance(); and in the cpp-file: void CMessenger: eleteInstance(){ if (mpMessenger) { delete mpMessenger; mpMessenger = NULL; } } But I only get this linker error: =================================== Error 19 error LNK2028: unresolved token (0A000293) "public: static class MessLib::CMessenger & __cdecl MessLib::CMessenger: eleteInstance(void)"(?DeleteInstance@CMessenger@MessLib@@$$FSAAAV12@XZ ) referenced in function "public: static class DotNetMessLib::Messenger ^ __clrcall DotNetMessLib::Messenger: eleteInstance(void)"(?DeleteInstance@Messenger@DotNetMessLib@@$$FSMP$A AV123@XZ) Messenger.obj =================================== and the (I think resulting) linker error: Error 20 error LNK2019: unresolved external symbol "public: static void __cdecl MessLib::CMessenger: eleteInstance(void)"(?DeleteInstance@CMessenger@MessLib@@$$FSAXXZ) referenced in function "public: static void __clrcall DotNetMessLib::Messenger: eleteInstance(void)"(?DeleteInstance@Messenger@DotNetMessLib@@$$FSMXXZ ) Messenger.obj =================================== The msdn-help is not really helpful: "When attempting to import a native function into a pure image, remember that the implicit calling conventions differ between native and pure compilations." But I don't use a pure image. I just compile my wrapper with /clr, not /clr ure.I've seen that some people get the same problems, but they worked with preprocessor-macros. The only macros in my code are: #ifndef _MESSENGER_H_ #define _MESSENGER_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 .... #endif // _MESSENGER_H_ My wrapper code looks like: void DotNetMessLib::Messenger: eleteInstance(){ MessLib::CMessenger: eleteInstance();mpMessenger = nullptr; } (in the header-file this method is defined static: static void DeleteInstance() ![]() To access the classes from the native library I included the native "messenger.lib" file in my wrapper project settings. What did I do wrong? How can I avoid these linker errors? Thanks a lot for your help! Best regards Ralf |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |