Also Talking about EVC engineering Transplantation

Source: Internet
Author: User

This article is a specific porting project for the author, listing all the problems encountered and providing specific solutions. Because it is a specific project, we cannot include all EVC engineering porting problems. Therefore, before porting a project, we recommend that you read the following articles:
Step by step: migrate eMbedded Visual C ++ applications to Visual Studio 2005
EMbedded Visual C ++ to Visual Studio 2005 Upgrade Wizard (note the last sentence: by default, embedded Visual C ++ 4.0 sets the dialog box style (Border) of the MFC Pocket PC Application to DS_MODALFRAME. This style is not supported by MFC 8.0. -- Thin should be changed. If Thin is not changed, the window will not pop up .)
Known problems caused by transplantation from eVC
Migrating Microsoft eMbedded Visual C ++ Projects to Visual Studio 2005
Development Environment: Windows XP + SP2, Visual Studio 2005 professional, and Windows Mobile 6.0 Professional SDK.
Note: (1) programs developed by the Windows Mobile 5.0 SDK can run in Windows Mobile 6.0 without any modifications.
(2) due to some errors and environment configuration problems, you must modify all the errors in Debug/Resease mode. In the following errors, after the label, "The Resealse mode also needs to be changed" is entered. Switch to another SDK on the same day, such as the Windows Mobile 5.0 SDK, which also needs to be modified.
In Debug mode:
1. StdAfx. cpp (the Resealse mode also needs to be changed)
Compilation error: D: \ Program Files \ Microsoft Visual Studio 8 \ VC \ ce \ atlmfc \ include \ afxver _. h (77): fatal error C1189: # error: Please use the/MD switch for _ AFXDLL builds
Solution: Right-click the Project name, open the Project properties dialog box, switch to the C/C ++-> Code generation page, and set Runtime Libarary to "Multi-threaded DLL (/MD) to solve this problem.
2. Compilation error: error C2065: 'I': undeclared identifier
Cause: the following code segment exists:
For (int I = 0; I <MAX_LEN; I ++)
{
//......
}
For (I = 0; I <MAX_NUM; I ++)
{
//......
}
After evc leaves the loop, the loop variable is still valid and can still be used, but it cannot be used in VS2005. Therefore, VS2005 is more rigorous in defining and reviewing variables, in addition, the array out-of-bounds problem is also better than EVC.
Solution: (you cannot fully trust the compiler or throw all the syntax checks to the compiler)
Int I = 0;
For (I = 0; I <MAX_LEN; I ++)
{
//......
}
For (I = 0; I <MAX_NUM; I ++)
{
//......
}
3. error C2664: '_ wcsnicmp': cannot convert parameter 2 from 'lpword' to 'const wchar_t *'
Forced type conversion is required.
4. error C2061: syntax error: identifier 'helpinfo'
Add the HELPINFO type and the header file HelpInfo. h.
5. error C2146: syntax error: missing '; 'before identifier' m _ wndCommandBar'
Cause: the CCeCommandBar class is replaced by CCommandBar in Windows Mobile 5.0/6.0.
Solution:
CCeCommandBar m_wndCommandBar; ----> CCommandBar m_wndCommandBar;
6. error C2065: 'num _ TOOL_TIPS ': undeclared identifier
Solution:
// # If defined (_ WIN32_WCE_PSPC) & (_ WIN32_WCE> = 212)
# Define NUM_TOOL_TIPS 8
// # Endif
7. error C3861: 'On _ WM_HELPINFO ': identifier not found
Same as 4
8. error C2440: 'static _ cast': cannot convert from 'void (_ cdecl CMyAppView: *) (void) 'to 'lresult (_ cdecl CWnd :: *) (WPARAM, LPARAM) 'none of the functions with this name in scope match the target type
Solution:
Afx_msg void OnHotLinkExplain (); ---> ();---〉
Afx_msg LRESULT OnHotLinkExplain (WPARAM wParam, LPARAM lParam );
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 needs to be forcibly converted
PDC-> GetTextExtent (& I, 1). cx); -->
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 'cdialout'
Solution: replace OnHelpInfo with TRUE'
Return CView: OnHelpInfo (pHelpInfo); --> return TRUE;
11. error C2039:'m _ bShowSharedNewButton ': is not a member of 'ccommandbar'
D: \ Program Files \ Microsoft Visual Studio 8 \ VC \ ce \ atlmfc \ include \ afxext. h (557): see declaration of 'ccommandbar'
Solution:
Comment out m_wndCommandBar.m_bShowSharedNewButton = FALSE;
12.. \ MyApp. rc (380): fatal error RC1015: cannot open include file 'wceres. rc '.
Solution:
Comment out: # include "wceres. rc" // WCE-specific components
However, this error is annoying. You have to modify this statement every time you modify the resource file.
13. Modify the Resease Mode
Error LNK2019: unresolved external symbol SHInitExtraControls referenced in function "protected: _ cdecl CMyAppView: CMyAppView (void )"(?? 0CMyAppView @ fa @ XZ)
Problem: SHInitExtraControls () is called in the program ();
Error LNK2019: unresolved external symbol SHSipPreference referenced in function "protected: void _ cdecl CMyAppView: OnKillfocusWord (void )"(? OnKillfocusWord @ CMyAppView @ IAAXXZ)
Problem: The SHSipPreference is called in the program.
The above two functions are in: Library: aygshell. lib.
Solution:
Project --> Property --> Linker --> input --> Additional Denpendencies: aygshell. lib
14. Modify the Resease Mode
Orelibc. lib (wwinmain. obj): error LNK2019: unresolved external symbol wWinMain referenced in function wWinMainCRTStartup
Attribute-> Linker-> Anvanced-> EntryPoint
Change wWinMainCRTStartup to WinMainCRTStartup
The Entry Point is WinMainCRTStartup (ANSI) or wWinMainCRTStartup (UINCODE), that is,... WinMainCRTStartup or wWinMainCRTStartup will call WinMain or wWinMain.
15. error C3861: 'loadstdprofilesetting': identifier not found
Comment out the LoadStdProfileSettings function;
For specific functions of this function, see MSDN.
BTW: during compilation, some chained errors may occur due to the above errors, commonly known as the "Butterfly effect", such as error C2143: syntax error: missing '; 'before '}'
Error C2143: syntax error: missing '; 'before ','
Error C2143: syntax error: missing '; 'before '{'
Less '{', '}', ';', and so on. The above errors-main contradictions are solved, and the errors-errors conflict is solved. Besides, this project was previously compiled and approved under evc ide. It is impossible for MS to optimize or improve the compiler. It is always necessary to consider compatibility, be confident in yourself or your predecessors!
At this point, compilation can be passed, but the following problems occur during running:
16. Modify the Resease Mode
Press F5 to display the following dialog box:

Solution:
Right-click Properties of the Project-> General-> Project Defaults-> Use MFC:
Use MFC in a shared DLL --> Use MFC in a static DLL
It is precisely because of this that the EXE program generated by VS2005 is more than 200 k larger than that generated by EVC.

In this way, the program is basically transplanted, but all the functions must be passed over, which may be encountered, such as garbled dialog box and incorrect menu.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.