您的位置:首页 > 大数据 > 人工智能

VS2012常见错误及解决方法

2015-05-09 11:53 483 查看
VS2012常见错误及解决方法

1.当建立Win32 Console Application时,程序入口函数是

    int main(){}  或者
 int _tmain(int argc, _TCHAR*
argv[]){} 

正确配置是:

Configuration Properties->C\C++->Preprocessor->PreprocessorDefinitions:  

WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)

Configuration Properties->Linker->System->SubSystem:
 

Console (/SUBSYSTEM:CONSOLE)

如果配置不正确,就会出现下面的错误:

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Error 1
error LNK2019: unresolved external symbol _WinMain@16referenced in function ___tmainCRTStartup

Error 2
error LNK1120: 1 unresolved externals

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    2.当建立Win32 Project时,程序入口函数是

int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,

                      _In_opt_ HINSTANCE hPrevInstance,

                          _In_ LPTSTR    lpCmdLine,

                                                _In_ int       nCmdShow){}        

 正确配置是:

Configuration Properties->C\C++->Preprocessor->PreprocessorDefinitions: 

 WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)

Configuration Properties->Linker->System->SubSystem:  

WINDOWS(/SUBSYSTEM:WINDOWS)

如果配置不正确,就会出现下面的错误:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Error 1
error LNK2019: unresolved external symbol
4000
_main
referenced in function ___tmainCRTStartup

Error 2
error LNK1120: 1 unresolved externals

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     3.当建立MFC Applicationt时,程序入口函数是

int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,_In_
LPTSTR lpCmdLine, int nCmdShow){}

正确配置是:

Configuration
Properties->C\C++->Preprocessor->PreprocessorDefinitions:  

WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)

Configuration Properties->Linker->System->SubSystem:  

WINDOWS(/SUBSYSTEM:WINDOWS)

如果配置不正确,就会出现下面的错误:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Error 1
error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

Error 2
error LNK1120: 1 unresolved externals

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息