Linking error: undefined reference to `WinMain'

3,051 views
Skip to first unread message

gp

unread,
Apr 9, 2015, 9:43:04 AM4/9/15
to cppu...@googlegroups.com
Hi all,

I have built the framework and ran some testing examples successfully.

But now, I'm trying to integrate the framework to a real project and I'm getting the next linking error:


make -f makefile.test
Linking uartSample_main_tests
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../lib/libcygwin.a(libcmain.o): In
function `main':
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39: undefined refere
nce to `WinMain'
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39:(.text.startup+0x
7e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMai
n'
collect2: error: ld returned 1 exit status
../../../Test/CppUTest/build/MakefileWorker.mk:464: recipe for target 'uartSampl
e_main_tests' failed
make: *** [uartSample_main_tests] Error 1



What could be the problem?

I appreciate your help!


Thanks a lot.

Regards,
Giovanni

Wayne J

unread,
Apr 9, 2015, 12:18:49 PM4/9/15
to cppu...@googlegroups.com

On Apr 9, 2015, at 6:43 AM, gp <gxp...@gmail.com> wrote:

usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39: undefined refere
nce to `WinMain'

It is now building as a Windows GUI application and you are not providing a WinMain(), the Windows version of main.

Wayne

gp

unread,
Apr 9, 2015, 4:26:16 PM4/9/15
to cppu...@googlegroups.com
Hi Wayne,

Thanks for your answer.

I need to build from a cmd window (console) not like Windows GUI.

What should I change to do this?

Thanks a lot!

Giovanni

Wayne J

unread,
Apr 9, 2015, 7:21:24 PM4/9/15
to cppu...@googlegroups.com

> On Apr 9, 2015, at 1:26 PM, gp <gxp...@gmail.com> wrote:
>
> Hi Wayne,
>
> Thanks for your answer.
>
> I need to build from a cmd window (console) not like Windows GUI.
>
> What should I change to do this?
>

I am sure it has something to do with the compiler/linker flags you are using. This will probably depend on the compiler you are using.

Unfortunately, it has been some time since I have really worked on Windows so I don’t know the specific answer. I am sure that Google will provide the answer *if* you can come up with the correct search terms.

Wayne

A. Robert S.

unread,
Apr 13, 2015, 10:38:43 AM4/13/15
to cppu...@googlegroups.com
Hi Giovanni,
 
It's rather unusual for Cygwin Gcc to want to build a Windows GUI application - what kind of Makefile are you using? What does your main() function look like?
 
Regards
Robert

gp

unread,
Apr 20, 2015, 2:05:36 PM4/20/15
to cppu...@googlegroups.com
Hi Robert,

It is solved, the runner code was missing.

Thanks a lot!.
Reply all
Reply to author
Forward
0 new messages