2010-12-07 7 views
20

VS proyecto C++ Biblioteca CLR 2010, los errores en la adición de la biblioteca comutil.h# include <comutil.h> causar errores

> Error 20 error LNK2001: unresolved 
> external symbol "extern "C" long 
> __stdcall VariantCopy(struct tagVARIANT *,struct tagVARIANT const 
> *)" ([email protected]@[email protected]@[email protected]@Z) D:\Projects\AL\Service\ncFlow\ncOPClient.NET\Stdafx.obj ncOPClient.NET 
> Error 18 error LNK2001: unresolved 
> external symbol "extern "C" void 
> __stdcall VariantInit(struct tagVARIANT *)" 
> ([email protected]@[email protected]@@Z) D:\Projects\AL\Service\ncFlow\ncOPClient.NET\Stdafx.obj ncOPClient.NET 
> Error 13 error LNK2001: unresolved 
> external symbol "void __stdcall 
> _com_issue_error(long)" ([email protected]@[email protected]) D:\Projects\AL\Service\ncFlow\ncOPClient.NET\Stdafx.obj ncOPClient.NET 
> Error 10 error LNK2028: unresolved 
> token (0A000376) "void __stdcall 
> _com_issue_error(long)" ([email protected]@[email protected]) 
> referenced in function "void __cdecl 
> _com_util::CheckError(long)" ([email protected][email protected]@[email protected]) D:\Projects\AL\Service\ncFlow\ncOPClient.NET\Stdafx.obj ncOPClient.NET 
> Error 4 error LNK2028: unresolved 
> token (0A0003BC) "extern "C" void 
> __stdcall VariantInit(struct tagVARIANT *)" 
> ([email protected]@[email protected]@@Z) 
> referenced in function "public: 
> __thiscall _variant_t::_variant_t(class _variant_t const &)" ([email protected]@[email protected]@@Z) D:\Projects\AL\Service\ncFlow\ncOPClient.NET\Stdafx.obj ncOPClient.NET 
> Error 2 error LNK2028: unresolved 
> token (0A0003D1) "extern "C" long 
> __stdcall VariantCopy(struct tagVARIANT *,struct tagVARIANT const 
> *)" ([email protected]@[email protected]@[email protected]@Z) 
> referenced in function "public: 
> __thiscall _variant_t::_variant_t(class _variant_t const &)" ([email protected]@[email protected]@@Z) D:\Projects\AL\Service\ncFlow\ncOPClient.NET\Stdafx.obj ncOPClient.NET 

necesario para

private: 
     std::string from_variant(VARIANT& vt) 
     { 
      _bstr_t bs(vt); 
      return std::string(static_cast<const char*>(bs)); 
     } 
     /* 
     void to_variant(const std::string& str, VARIANT& vt) 
     { 
      _bstr_t bs(str.c_str()); 
      reinterpret_cast<_variant_t&>(vt) = bs; 
     }*/ 

cómo puedo solucionarlo?

Respuesta

22

Según MSDN, _bstr_t requiere comsuppw.lib. Agregue esta biblioteca a la lista de dependencias del enlazador.

+0

¿Versión de char ancha? http://msdn.microsoft.com/en-us/library/x295h94e(v=VS.71).aspx –

+0

Sí, ayudó) Gracias. – Cynede

+10

No necesita jugar con la configuración del enlazador. '#include ' es suficiente; emitirá la configuración correcta del enlazador por medio de '#pragma comment (lib, ...)', en función de si se define '_DEBUG' o no. – IInspectable

38

intente incluir comdef.h, no incluya comutil.h

+3

Excelente conocimiento arcano. Funciona de maravilla. –

+0

Acabas de salvar mi vida (estaba usando comip.h). ¡Gracias! – S200

+0

Porque 'comdef.h' tiene pragmas como' # pragma comment (lib, "comsuppw.lib") 'incluido. Que, por otro lado, 'comutil.h' no contiene. – Florian

Cuestiones relacionadas