使用gcc对 C 代码进行编译时提示undefined reference to `WinMain',collect2.exe: error: ld returned 1 exit status;详细的信息大致如下:

省略...
:crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status

出现这种情况表示 C 代码中不存在入口函数,即main()函数,请为你的 C 程序添加main()函数;

int main(int argc, char* argv[]) {

}

对于刚编写的代码,请检查是否已保存。