Search code examples
c++comlinkerc-stringslnk2005

LINKER error: comsupp.lib and comsuppwd.lib


error is:

Error 14 error LNK2005: "void __stdcall _set_com_error_handler(void (__stdcall*)(long,struct IErrorInfo *))" (?_set_com_error_handler@@YGXP6GXJPAUIErrorInfo@@@Z@Z) already defined in comsupp.lib(comsupp.obj) comsuppwd.lib

Did anyone run into this before?


Solution

  • Error is resolved now. The cause of error was a header file: #include <msclr\marshal_cppstd.h> and conversion from System::String^ to std::string(I found a similar issue here):

    //commented out following 3 lines and problem solved:
    //looks like following type conversion has problems:
    #include <msclr\marshal_cppstd.h>
    msclr::interop::marshal_context marshal_context_1;
    string_TempDir_XMLfiles=marshal_context_1.marshal_as<std::string>(String_Ptr_Destin_Dir_XMLfiles);