点滴记录学习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;