[英]Undefined reference to 'WinMain@16' C error
I am using Eclipse (C programming) and I have come up with this code but every time I build it, I get the error saying, "Undefined Reference to 'WinMain@16'". 我正在使用Eclipse(C编程),我已经提出了这个代码,但每次构建它时,我都会收到错误消息“未定义引用'WinMain @ 16'”。 I have spent over 2 hours trying to solve this problem but I can't figure out my where my error is.
我花了2个多小时试图解决这个问题,但我无法弄清楚我的错误在哪里。 Can anyone help?
有人可以帮忙吗?
This is the code: 这是代码:
#include <stdio.h>
int main(void)
{
int input;
printf("Please enter an integer:\n");
scanf("%d",&input);
int temp = input;
while(input<=temp+10)
{
printf("%d ",input);
input++;
}
printf("\n");
return 0;
}
When you compile or build, files are not automatically saved to disk by Eclipse. 编译或构建时,Eclipse不会自动将文件保存到磁盘。 But the compiler is using the on-disk files.
但编译器正在使用磁盘上的文件。 So maybe you just didn't save the file after you've added the main function.
所以也许你在添加main函数后没有保存文件。
If you are compiling the right and saved file, you have to make sure you are compiling it with the subsystem target set to console, when you're using the main
entry point. 如果要编译正确且已保存的文件,则必须确保在使用
main
入口点时将子系统目标设置为控制台进行编译。
You can do this changing the makefile. 你可以这样做改变makefile。
If you don't know how to do this, or if you're not using a makefile and don't want to change the compiler's parameters line, you can use this directive: 如果您不知道如何执行此操作,或者如果您不使用makefile并且不想更改编译器的参数行,则可以使用此指令:
#pragma comment(linker, "/subsystem:console")
WinMain
is normally used for /subsystem:windows
type of programs, and as you are trying to make a console application, you should use /subsystem:console
and the main
entry point. WinMain
通常用于/subsystem:windows
类型的程序,当您尝试创建控制台应用程序时,您应该使用/subsystem:console
和main
入口点。
Again, make sure you are compiling the right file on the disk. 再次确保您正在编译磁盘上的正确文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.