I am trying to link a MFC exe project in VC7 and I am having problem with the _variant_t object. The error I get is:
targets.obj : error LNK2019: unresolved external symbol "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)" (?ConvertStringToBSTR@_com_util@@YGPA_WPBD@Z) referenced in function "public: __thiscall _variant_t::_variant_t(char const *)" (??0_variant_t@@QAE@PBD@Z)
It seems that the problem is with the ConvertStringToBSTR function. I have tested a project with just the piece of code that appears in the MSDN help for the ConvertStringToBSTR and I get the same error. The code is:
char* lpszText = "Test";
printf("char * text: %s\n", lpszText);
BSTR bstrText = _com_util::ConvertStringToBSTR(lpszText);
wprintf(L"BSTR text: %s\n", bstrText);
SysFreeString(bstrText);
I have used the #include <comutil.h> and I have linked with the comsupp.lib library.
I have tested the same code with a Win32 project (no MFC) and it works fine, so the problem has something to do with MFC? How can I solve it?
Any help will be appreciate!!
Thanks in advance.
targets.obj : error LNK2019: unresolved external symbol "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)" (?ConvertStringToBSTR@_com_util@@YGPA_WPBD@Z) referenced in function "public: __thiscall _variant_t::_variant_t(char const *)" (??0_variant_t@@QAE@PBD@Z)
It seems that the problem is with the ConvertStringToBSTR function. I have tested a project with just the piece of code that appears in the MSDN help for the ConvertStringToBSTR and I get the same error. The code is:
char* lpszText = "Test";
printf("char * text: %s\n", lpszText);
BSTR bstrText = _com_util::ConvertStringToBSTR(lpszText);
wprintf(L"BSTR text: %s\n", bstrText);
SysFreeString(bstrText);
I have used the #include <comutil.h> and I have linked with the comsupp.lib library.
I have tested the same code with a Win32 project (no MFC) and it works fine, so the problem has something to do with MFC? How can I solve it?
Any help will be appreciate!!
Thanks in advance.