如何解决“无法解析的外部符号”问题Visual C++ 中的链接错误?
我有 Visual Studio C++ 2008 Express 版本。
我正在尝试编译一个程序,但收到以下链接错误:
1>MSVCRT.lib(wcrtexew.obj) : error LNK2001: unresolved external symbol _wWinMain@16
我试图做什么:
我在谷歌上找到了这个:
For Visual C++ .NET: In the Advanced category of the Linker folder in the Project Properties dialog box, set the Entry Point to wWinMainCRTStartup.
它本来可以工作,但没有。我如何编译这个应用程序?
代码非常简单:
#include "stdafx.h"
int main( int argc, char ** argv )
{
}
I Have the Visual Studio C++ 2008 Express Edition.
I am trying to compile a program but I am getting the following Link Error:
1>MSVCRT.lib(wcrtexew.obj) : error LNK2001: unresolved external symbol _wWinMain@16
What I tried to do:
I found this on google:
For Visual C++ .NET: In the Advanced category of the Linker folder in the Project Properties dialog box, set the Entry Point to wWinMainCRTStartup.
It was intended to work but didn't. How do I compile this app?
The code is stupidly simple:
#include "stdafx.h"
int main( int argc, char ** argv )
{
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有多种方法可以解决此问题:
定义
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow );
而不是int main(int argc, char const ** argv)
更改字符集以使用 Unicode 字符集(项目设置 -> 常规 -> 字符集)
There are multiple ways to solve this:
Define
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow );
instead ofint main(int argc, char const ** argv)
Change the Character Set to Use Unicode Character Set (Project Settings -> General->Character Set )
看起来您在创建项目时选择了一个 GUI(Win32、MFC 等)程序。
这些程序有一个 WinMain() 而不是 main()。
您想要的是一个控制台项目。
It looks like when you created your project you selected a GUI (Win32, MFC, etc) program.
Those programs have a WinMain() instead of a main().
What you want is a Console project.
根据 类似问题,发生该错误当
main
未定义时。也许由于某种原因它正在编译不同的文件?
此答案表明您的标志可能不一致。
According to similar questions, that error happens when
main
isn't defined.Maybe for some reason it's compiling a different file?
This answer suggests that maybe your flags are inconsistent.