VS2005 學習記錄3-移植處理

點滴記錄學習VS2005過程所遇到的問題,及解決方法c++

1.將EVC4的工程轉化成.net2005時要將工程的屬性中的c/c++->代碼生成->運行時庫改成:多線程DLL(/MD)shell

2.在工程的屬性中的連接器->高級->入口點改成:WinMainCRTStartup編程

3.WINVER      not      defined.      Defaulting      to      0x0501,問題緣由:在工程的屬性c/c++->預處理器->預處理器定義中加上_WIN32_WINNT=0x500試試數組

 

 

1.Error:uafxcwd.lib的處理多線程

VS2005 CE6.0編程, 寫一個LIB給應用調用app

在應用調用LIB時產生錯誤, 信息詳細信息:uafxcwd.lib(afxinl1.obj) : error LNK2005: "public: virtual void __cdecl CObject::Serialize(class CArchive &)" (?Serialize@CObject@@UAAXAAVCArchive@@@Z) 已經在 mfc80ud.lib(MFC80UD.DLL) 中定義ide

錯誤緣由:工程和LIB的編譯選項要一致。函數

包括字符集 Unicode, Multi-Byte...  運行庫    MDD, MTD ...學習

產生這次錯誤的具體緣由是:工程和LIB在設置中的「常規」/MFC的使用 項,選擇不一致,致使此錯誤。ui

 

 

2.關閉 C4996 警告

例如:warning C4996: strncpy was declared deprecated

辦法是在編譯選項 C/C++ | Preprocessor | Preprocessor Definitions中,增長_CRT_SECURE_NO_DEPRECATE

也能夠使用如下方法:

#pragma   warning(disable:4996)   //所有關掉 #pragma   warning(once:4996)      //僅顯示一個

 

 

3.若是出現如下錯誤:

_CE_ACTIVEX was not defined because this Windows CE SDK does not have DCOM. _CE_ACTIVEX could be caused to be defined by defining _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA, but it is recommended that this be done only for single-threaded apps. _ATL_NO_HOSTING was defined because _CE_ACTIVEX was not defined.

解決方法:在stdafx.h文件里加上#define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA

 

4.若出現如下錯誤:

fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds

解決方法:右擊工程名,打開Project properties對話框,切換到C/C++->Code generation頁,將Runtime Libarary 設置成「Multi-threaded DLL(/MD)」,便可解決此問題

 

 

5.若出現如下錯誤:

error C2664: '_wcsnicmp' : cannot convert parameter 2 from 'LPWORD' to 'const wchar_t *'

解決方法:強制類型轉換

 

6.若出現錯誤:

error C2065: 'i' : undeclared identifier

緣由分析:對於evc離開循環後,循環變量仍然有效,而且仍能夠使用,可是在VS2005下是不行的,因而可知VS2005對變量的定義與審查更爲嚴格,還有就是對數組越界問題也比EVC來的強。

解決方法:

int i = 0;

for (i = 0; i < MAX_LEN; i ++)

{

}

for (i = 0; i < MAX_NUM; i ++)

{

}

 

7.若出現如下錯誤:

error C2146: syntax error : missing ';' before identifier 'm_wndCommandBar'

緣由分析:在Windows Mobile 5.0/6.0 下CCeCommandBar類被CCommandBar替換

解決方法:用CCommandBar     m_wndCommandBar;代替CCeCommandBar     m_wndCommandBar;

 

8.若出現如下錯誤:

error C2061: syntax error : identifier 'HELPINFO' 或 'ON_WM_HELPINFO'

解決方法:增長HELPINFO的類型,增長頭文件HelpInfo.h

 

9.若出現如下錯誤:

error C2664: 'CSize CDC::GetTextExtent(LPCTSTR,int) const' : cannot convert parameter 1 from 'WORD *' to 'LPCTSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast須要強制轉換

解決方法:強制轉換,例如使用pDC->GetTextExtent((LPCTSTR)&i, 1).cx;

 

10.若是出現如下錯誤:

error C2039: 'OnHelpInfo' : is not a member of 'CView' error C2039: 'OnHelpInfo' : is not a member of 'CFrameWnd' error C2039: 'OnHelpInfo' : is not a member of 'CDialog'

解決方法:用TRUE替換相應的類成員函數OnHelpInfo,即用return TRUE;代替return CView::OnHelpInfo(pHelpInfo);

 

11.若是出現如下錯誤:

error C2039: 'm_bShowSharedNewButton' : is not a member of 'CCommandBar' D:Program FilesMicrosoft Visual Studio 8VCceatlmfcincludeafxext.h(557) : see declaration of 'CCommandBar'

解決方法:直接註釋掉 m_wndCommandBar.m_bShowSharedNewButton = FALSE;

 

12.fatal error RC1015: cannot open include file Mobile.rc'.

解決方法:直接註釋掉:#include "wceres.rc"           // WCE-specific components

或 從屬性頁中的「資源」/「資源文件名」從刪除RC文件

 

13.若在Resease 模式下出現如下錯誤:

error LNK2019: unresolved external symbol SHInitExtraControls referenced in function "protected: __cdecl CMyAppView::CMyAppView(void)" (   0CMyAppView@@IAA@XZ)

緣由分析:程序中調用了SHInitExtraControls();

error LNK2019: unresolved external symbol SHSipPreference referenced in function "protected: void __cdecl CMyAppView::OnKillfocusWord(void)" (OnKillfocusWord@CMyAppView@@IAAXXZ)

問題:程序中調用了SHSipPreference

以上兩個函數都在:Library: aygshell.lib裏

解決方法:工程-->屬性-->Linker -->input -- > Additional Denpendencies :aygshell.lib

 

14.若出現如下錯誤:

orelibc.lib(wwinmain.obj) : error LNK2019: unresolved external symbol wWinMain referenced in function wWinMainCRTStartup

解決方法:屬性—〉Linker—〉Anvanced—〉EntryPoint 將 wWinMainCRTStartup 更改成 WinMainCRTStartup,Entry Point是WinMainCRTStartup(ANSI)或wWinMainCRTStartup(UINCODE),即: ... WinMainCRTStartup 或wWinMainCRTStartup 會調用WinMain 或wWinMain。

 

15.若出現如下錯誤:

error C3861: 'LoadStdProfileSettings': identifier not found

解決方法:註釋掉函數 LoadStdProfileSettings;

相關文章
相關標籤/搜索