天天看點

【IDE-Visual Studio】fatal error C1047問題原因解決方法

問題

1>------ 已啟動生成: 項目: GelPrj, 配置: Release Win32 ------
1>正在編譯...
1>camera_config.cpp
1>..\functions\camera_config.cpp(1057) : warning C4018: '<' : signed/unsigned mismatch
1>正在連結...
1>fatal error C1047: The object or library file '..\temp\release\Contrast_Dye.obj' was created with an older compiler than other objects; rebuild old objects and libraries
1>LINK : fatal error LNK1257: 代碼生成失敗
1>正在建立浏覽資訊檔案...
1>Microsoft ?????????? Version 8.00.50727
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>生成日志儲存在“file://e:\svn4\trunk_lite\temp\Release\BuildLog.htm”
1>GelPrj - 1 個錯誤,1 個警告
========== 生成: 0 已成功, 1 已失敗, 0 最新, 0 已跳過 ==========
           

原因

有些函數寫了聲明沒有寫實作的是以出現下面的錯誤, 為什麼編譯的時候沒有出現“無法解析的外部符号”的提示,可能是由于目前vs版本過高的緣故

解決方法

第一步、找到函數沒有寫實作的地方

修改工程屬性 配置屬性->正常->項目預設值->MFC的使用=在靜态庫中使用MFC

【IDE-Visual Studio】fatal error C1047問題原因解決方法

第二步、編譯

出現以下提示

1>正在編譯資源...
1>正在連結...
1>MSVCRT.lib(MSVCR80.dll) : error LNK2005: __strnicmp 已經在 libcmt.lib(strnicmp.obj) 中定義
1>MSVCRT.lib(MSVCR80.dll) : error LNK2005: _free 已經在 libcmt.lib(free.obj) 中定義
1>MSVCRT.lib(MSVCR80.dll) : error LNK2005: _malloc 已經在 libcmt.lib(malloc.obj) 中定義
1>MSVCRT.lib(MSVCR80.dll) : error LNK2005: _calloc 已經在 libcmt.lib(calloc.obj) 中定義
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@[email protected]@@Z) 已經在 libcmt.lib(typinfo.obj) 中定義
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@[email protected]@@Z) 已經在 libcmt.lib(typinfo.obj) 中定義
1>LINK : warning LNK4098: 預設庫“MSVCRT”與其他庫的使用沖突;請使用 /NODEFAULTLIB:library
1>DlgCameraView.obj : error LNK2001: 無法解析的外部符号 "class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > > __cdecl ccd_data_center::run(class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > >,int,float)" ([email protected]_data_center@@[email protected][email protected][email protected]@ATL@@@@@ATL@@[email protected]@Z)
1>../bin/Lane 1D.exe : fatal error LNK1120: 1 個無法解析的外部指令
1>正在建立浏覽資訊檔案...
1>Microsoft ?????????? Version 8.00.50727
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>e:\svn4\trunk_lite\temp\release\excel.tlh(667) : BK4504 : 
1>生成日志儲存在“file://e:\svn4\trunk_lite\temp\Release\BuildLog.htm”
1>GelPrj - 8 個錯誤,13 個警告
========== 生成: 0 已成功, 1 已失敗, 0 最新, 0 已跳過 ==========
           

第三步、找出“無法解析的外部符号”,中的關鍵字元并完成對應函數的實作

如上面的錯誤代碼所示,DlgCameraView.obj 中引用的ccd_data_center::run函數沒有寫實作,找到ccd_data_center::run函數聲明的地方,并實作它

第四步、将工程屬性改回

配置屬性->正常->項目預設值->MFC的使用=在共享 DLL 中使用 MFC