EVC移植问题和编译wince console Application(EVC 控制台程序)的方法

    技术2022-05-11  10

    今天在移植一个C++代码到EVC上,出现了如下一些错误"corelibc.lib(pegwmain.obj) : error LNK2019: unresolved external symbol WinMain referenced in function WinMainCRTStartup",和"corelibc.lib(wwinmain.obj) : error LNK2019: unresolved external symbol wWinMain referenced in function wWinMainCRTStartup"。解决这些错误又让我知道了如何在EVC上编译wince console Application(EVC 控制台程序和了解main()、WinMain()、wmain()、 _tmain()、DllMainCRTStartup 、mainWCRTStartup 、WinMainCRTStartup 这些的驱别,现总结整理如下:

     

    1、今天在移植一个C++代码到EVC上,入口函数是int main (int argc, char ** argv),创建EVC WCE Application工程,并包含相关代码,编译并修改了一些错误,最后的错误如下:"corelibc.lib(pegwmain.obj) : error LNK2019: unresolved external symbol WinMain referenced in function WinMainCRTStartup",按照一些网友的说法,又在属性—〉Linker—〉Anvanced—〉EntryPoint

    将 WinMainCRTStartup 更改为 wWinMainCRTStartup,结果仍然出错为"corelibc.lib(wwinmain.obj) : error LNK2019: unresolved external symbol wWinMain referenced in function wWinMainCRTStartup",分析程序和错误原因,是因为WinMainCRTStartup 或wWinMainCRTStartup 会调用WinMain 或wWinMain,而在移植的C++代码没有相应的实现,即win32程序是以一个WinMain函数作为程序的进入点,主程序为Winmain,不是main,所以出错。由于现在的这个程序是控制台程序,所以我就想创建wince console Application,但在EVC上没有这个wce console Application,所以在网上查找相关资料,总算知道如何在EVC上创建控制台程序,

    2、如何在EVC上创建控制台程序               Below are steps to write a console application using eVC:Step1: Open eVC, and create a new project: File --> New... --> WCE Application --> OK.

    Step2: Choose "An empty project"

    Step3: Create a new C++ source file, and in that file, add #include "windows.h"

    Step4: Moreover add the following codes in above C++ source file as entry point:int WINAPI _tmain(int argc, char ** argv){printf("Hello mike!");return 0;}

    Step5: Project --> Settings --> Link tab --> Category = Output-->Entry-point symbol: WinMainCRTStartup ==> mainWCRTStartup

    最后编译工程就可以了。

    3、整理收集的资料

        win32程序是以一个WinMain函数作为程序的进入点,   而在你的程序中无法找到这个函数,   所以无法生成可执行文件。       Win32程序的主程序为Winmain,不是main.  

      main()是WINDOWS的控制台程序(32BIT)或DOS程序(16BIT), 是c/c++的标准入口函数名    WinMain()是WINDOWS的GUI程序, 是windows api窗体程序的入口函数    wmain()是UNICODE版本的main(),     _tmain()是个宏,如果是UNICODE则他是wmain()否则他是main()   DllEntry/DllMain -- calls entry supplied by module. Does NOT call C++ static ctors/dtors DllMainCRTStartup - calls C++ static ctors & dtors. Then calls module's DllMainWinMain -- calls module's standard EXE entry point. Does NOT call C++ static ctors/dtorsWinMainCRTStartup -- Calls C++ static ctors, then calls module's WinMainmainWCRTStartup -- for console apps whose entry is wmain(int argc, WCHAR **argv). Also calls C++ ctors/dtorsmainACRTStartup -- for console apps whose entry is main(int argc, char **argv). Also calls C++ ctors/dtors


    最新回复(0)