问题
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