简体   繁体   English

未定义的'WinMain @ 16'C错误引用

[英]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:consolemain入口点。

Again, make sure you are compiling the right file on the disk. 再次确保您正在编译磁盘上的正确文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C 编程对‘WinMain@16’的未定义引用 - C Programming undefined reference to `WinMain@16' C:未定义对“WinMain@16”的引用 - C: undefined reference to "WinMain@16' Gradle未定义引用`WinMain @ 16&#39;错误 - Gradle undefined reference to `WinMain@16' error 错误对“ WinMain @ 16”的未定义引用 - Error Undefined reference to 'WinMain@16' 无法在 CodeBlocks 上编译 C 程序:未定义对“WinMain@16”的引用 - Cannot compile C programs on CodeBlocks: Undefined reference to 'WinMain@16' 未定义引用“ WinMain @ 16” mingw转换为DLL - undefined reference to `WinMain@16' mingw converting to DLL 使用SDL时对WinMain @ 16的未定义引用 - Undefined reference to WinMain@16 when using SDL 未定义对“WinMain@16”collect2.exe 的引用:错误:ld 返回 1 退出状态 - undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status 我刚开始编码,但在 vscode 中出现了 undefined reference to winmain@16 这个错误 - I just started coding and I got this error undefined reference to winmain@16 in vscode 未定义对“ SDL_Init”的引用(对“ WinMain @ 16” collect2.exe的未定义引用:错误:ld返回了1个退出状态) - undefined reference to `SDL_Init' (undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM