在Cygwin中对WinMain的未定义引用 [英] Undefined reference to WinMain in Cygwin

查看:3871
本文介绍了在Cygwin中对WinMain的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译并遇到以下问题

I am trying to compile and having following problem

$ gcc errlib.c -o errlib.o

/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../lib/libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain'
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39:(.text.startup+0x7e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
collect2: error: ld returned 1 exit status

有任何建议吗?这些文件经过良好测试,生成的代码很好之前,但现在我认为可能有一些cygwin设置等... m在cygwin上的windows 8上编译。

Any suggestions? These files are well tested and generated the code fine before but now i think there might be some cygwin settings or so ... m compiling on windows 8 on cygwin.

推荐答案

使用 -c 编译标志仅生成目标文件。没有 -c 它尝试链接一个可执行文件和链接器(自动调用)失败。

Use -c compile flag to only produce object file. Without -c it tries to link an executable and the linker (called automatically) fails.

这篇关于在Cygwin中对WinMain的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆