2015-04-21 103 views
-1

錯誤是:連接錯誤:comsupp.lib和comsuppwd.lib

Error 14 error LNK2005: "void __stdcall _set_com_error_handler(void (__stdcall*)(long,struct IErrorInfo *))" ([email protected]@[email protected]@@[email protected]) already defined in comsupp.lib(comsupp.obj) comsuppwd.lib

沒有人以前碰到這個?

+0

的聲明和定義函數的簽名必須匹配。在你的情況下,定義不會改變,所以鏈接器不能通過它的聲明簽名來找到函數。 –

+0

@AlexeiAverchenko我修改了聲明和定義。我覺得這個錯誤與我的定義中的實現有關。 – user3405291

+1

對不起,我一開始並沒有看錯誤文字。看起來像一些函數是在多個對象文件中聲明的。例如,如果在頭文件中定義了函數體,就會發生這種情況。 –

回答

0

現在錯誤已解決。錯誤的原因是一個頭文件:#include <msclr\marshal_cppstd.h>和轉換從System::String^std::string(我發現了一個類似的問題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);