Linking errors when upgrading a VS2003 solution in C++

痞子三分冷 提交于 2019-12-13 08:23:59

问题


I've been struggling with upgrading this solution. It has both managed and unmanaged memory and includes calls to methods that Marshal the string variables. The linking errors I get are in pairs.

LNK2028 unresolved token void __cdecl function(wchar_t const *, wchar_t const * *) referenced in function public: void __clrcall NamespaceOfTheSolutionIAmWorkingOn::function(class System::String ^, cli::array ^)

and

LNK2019 unresolved external symbol void __cdecl function(wchar_t const *, wchar_t const * *) referenced in function public: void __clrcall NamespaceOfTheSolutionIAmWorkingOn::function(class System::String ^, cli::array ^)

I've obviously modified the error messages a bit to make them more readable, the real function has a long name and passes several ints as well.

Any help would be greatly appreciated!


回答1:


Well, I just found somebody at work who helped me through the solution. The key is wchar_t. Apparently, it was not a native type in VS2003, but we had code that identified it as an array of unsigned short ints. When linking it, there was a mismatch between wchar_t and unsigned short. So I had to turn OFF the option that treated wchar_t as a native type. Now it compiles and links. I'm going to have to probably tweak it a bit more to make sure it works as we intend.



来源:https://stackoverflow.com/questions/20106275/linking-errors-when-upgrading-a-vs2003-solution-in-c

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