I get LNK2028 when trying to wrap native c++ class using managed c++

走远了吗. 提交于 2019-12-10 13:45:32

问题


trying to wrap a native cpp class using managed c++ class.

all looks good but for some reason it wont compile.

getting the following linker errors:

Error 25 error LNK2028: unresolved token (0A0002CE) Error 27 error LNK2019: unresolved external symbol

Any ideas how do I fix this one ? :\

well, here is a full error of one of the functions:

Error 20 error LNK2028: unresolved token (0A0002CF) "public: bool __thiscall RCSclient::ResumeChannel(char *,int,__int64)" (?ResumeChannel@RCSclient@@$$FQAE_NPADH_J@Z) referenced in function "public: bool __clrcall RCSClientWrapper::RCSclientWrapper::ResumeChannel(class System::String ^,int,class System::DateTime ^)" (?ResumeChannel@RCSclientWrapper@RCSClientWrapper@@$$FQ$AAM_NP$AAVString@System@@HP$AAVDateTime@4@@Z) RCSClientWrapper.obj RCSClientWrapper

Tried to add the user32.lib with no results..

Ofer


回答1:


C++/CLI allows you to mix in native C++ pretty much at will, but using C++/CLI makes your app depend on the .NET framework.

The reason is your C++/CLI project doesn't have some libs (user32.lib, in example) setup in the linker input is that the .NET framework already provides similar services, and the IDE assumes that you prefer those to the older, native ones.

Check your project and add reference to the corresponding library.




回答2:


Maybe you forgot an virtual keyword into the native C++ header function declaration to call from managed wrapper!?



来源:https://stackoverflow.com/questions/721387/i-get-lnk2028-when-trying-to-wrap-native-c-class-using-managed-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!