想使程序 大小优化
使用了
#pragma comment(linker, "/ENTRY:WinMain") 的参数但是当 #include <string> stl库后
出现了 error LNK2001: unresolved external symbol _main
的错误.
有什么办法可以解决?
谢谢

解决方案 »

  1.   

    #pragma comment(linker, "/ENTRY:main") 试试?
      

  2.   

    优化程序大小可以这样
    #pragma comment(linker, "-merge:.rdata=.text")
    #pragma comment(linker, "-align:512")extern "C" void WinMainCRTStartup()
    {
         //你的代码
    }
      

  3.   

    根据MSDN的话语,似乎:
    /Entry 后面只可以接三种类型入口
    mainCRTStartup (or wmainCRTStartup)  用于普通控制台程序,这种入口会调用main或wmain
    WinMainCRTStartup(or wWinMainCRTStartup) 用于windows程序此入口调用WinMain或wWinMain
    _DllMainCRTStartup              用于DLL,调用DllMain所以你的程序如果是window程序的化
    就应该这样设置:
    #pragma comment(linker, "/ENTRY:WinMainCRTStartup")  (如果没用UNICODE)
    或 #pragma comment(linker, "/ENTRY:wWinMainCRTStartup")  (如果用UNICODE)或者你也可以在VC工程中设置
    click Settings on the Project menu. Then click the Link tab, and click Output in the Category box.)此方法已经经过简单的测试。