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 _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