C++错误unresolved external symbol _WinMain@16

C++错误unresolved external symbol _WinMain@16 
2008-10-26 13:00:28
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://younglab.blog.51cto.com/416652/108112 
今天在写c++作业时出现一个错误提示:
Linking... 
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 
Debug/test.exe : fatal error LNK1120: 1 unresolved externals 
Error executing link.exe. 


test.exe - 2 error(s), 0 warning(s)
查了一下,原来是环境配置问题,贴出来,希望遇到同样问题的能方便地解决问题
这个文件中使用了WinMian而不是main作为入口函数。vc这时的默认设置是针对控制台程序的。 
解决方法: 
1.进入project->setting->c/c++, 在category(第一行)中选择preprocessor,在processor definitions中删除_WINDOWS, 添加_CONSOLE 


2.进入project->setting->Link, 在Project options中将/subsystem:windows.改为/subsystem:console 


3.保存设置,Rebuild All.
本文出自 “阳阳的学习笔记” 博客,请务必保留此出处http://younglab.blog.51cto.com/416652/108112

: unresolved external symbol _WinMain@16

10-09

#include rnrn#include rnrnstatic OPENFILENAME ofn ;rnrnvoid PopFileInitialize (HWND hwnd) rn rnTCHAR szFilter[] = TEXT("文本文件(*.txt)\0*.text\0")TEXT("All Files (*.*)\0*.*\0\0");rn TCHAR szFileName[MAX_PATH + 1];rn OPENFILENAME ofn;rn memset(szFileName, 0, sizeof(MAX_PATH + 1));rn memset(&ofn, 0, sizeof(OPENFILENAME));rn ofn.lpstrFile = szFileName;rn ofn.lStructSize = sizeof (OPENFILENAME);rn ofn.hwndOwner = hwnd;rn ofn.hInstance = NULL;rn ofn.lpstrFilter = szFilter;rn ofn.lpstrCustomFilter = NULL;rn ofn.nMaxCustFilter = 0;rn ofn.nFilterIndex = 0;rn ofn.nMaxFile = MAX_PATH;rn ofn.nMaxFileTitle = MAX_PATH;rn ofn.lpstrInitialDir = NULL;rn ofn.lpstrTitle = NULL;rn ofn.Flags = 0;rn ofn.nFileOffset = 0;rn ofn.nFileExtension = 0;rn ofn.lpstrDefExt = TEXT("bmp");rn ofn.lCustData = 0;rn ofn.lpfnHook = NULL;rn ofn.lpTemplateName = NULL;rn GetOpenFileName(&ofn);rn MessageBox(hwnd, szFileName, 0, MB_OK); rn rn rn memset(szFileName, 0, sizeof(MAX_PATH + 1));rn memset(&ofn, 0, sizeof(OPENFILENAME));rn ofn.lpstrFile = szFileName;rn ofn.lStructSize = sizeof (OPENFILENAME);rn ofn.hwndOwner = hwnd;rn ofn.hInstance = NULL;rn ofn.lpstrFilter = szFilter;rn ofn.lpstrCustomFilter = NULL;rn ofn.nMaxCustFilter = 0;rn ofn.nFilterIndex = 0;rn ofn.nMaxFile = MAX_PATH;rn ofn.nMaxFileTitle = MAX_PATH;rn ofn.lpstrInitialDir = NULL;rn ofn.lpstrTitle = NULL;rn ofn.Flags = 0;rn ofn.nFileOffset = 0;rn ofn.nFileExtension = 0;rn ofn.lpstrDefExt = TEXT("bmp");rn ofn.lCustData = 0;rn ofn.lpfnHook = NULL;rn ofn.lpTemplateName = NULL;rn GetOpenFileName(&ofn);rn MessageBox(hwnd, szFileName, 0, MB_OK);rn;rn出现错误Linking...rnLIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16rnDebug/1237.exe : fatal error LNK1120: 1 unresolved externalsrnError executing link.exe.rnrn1237.exe - 2 error(s), 0 warning(s)rn更多 0 论坛

没有更多推荐了,返回首页