# Building on cygwin 64: undefined reference to \`WinMain'

**URL:** https://discourse.ats-lang.org/t/building-on-cygwin-64-undefined-reference-to-winmain/339
**Category:** Google Group
**Created:** [September 21, 2014, 2:00am UTC](https://discourse.ats-lang.org/t/building-on-cygwin-64-undefined-reference-to-winmain/339 "2014-09-21T02:00:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)
#### Post date: [September 21, 2014, 2:00am UTC](https://discourse.ats-lang.org/t/building-on-cygwin-64-undefined-reference-to-winmain/339/1 "2014-09-21T02:00:35Z")

</div>

This is after a fresh rebuilt of ATS1 and ATS2:

cp -f src/patsopt bin/patsopt  
make -C utils/atscc -f Makefile all  
make[1]: Entering directory ‘/home/brand\_000/ATS-Postiats/utils/atscc’  
  
gcc -I"/home/brand\_000/ATS-Postiats"  
-I"/home/brand\_000/ATS-Postiats"/ccomp/runtime -std=c99 -D\_XOPEN\_SOURCE  
-DATS\_MEMALLOC\_LIBC -O2 -o patscc patscc\_dats.c atscc\_main\_dats.c  
atscc\_print\_dats.c  
/usr/lib/gcc/x86\_64-pc-cygwin/4.8.3/…/…/…/…/lib/libcygwin.a(libcmain.o):  
In function `main': /usr/src/debug/cygwin-1.7.32-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to`WinMain’  
/usr/src/debug/cygwin-1.7.32-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  
Makefile:29: recipe for target ‘patscc’ failed  
make[1]: \*\*\* [patscc] Error 1  
make[1]: Leaving directory '/home/brand\_000/ATS-Postiats/utils/atscc’  
Makefile\_devl:39: recipe for target ‘src\_patscc’ failed  
make: \*\*\* [src\_patscc] Error 2

My only clue so far is that none of the \*.c files being compiled seem to  
include a main entry point, and this may be confusing cygwin’s linker.

---

<div class="post-metadata">

### Author: ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)
#### Post date: [September 26, 2014, 6:11pm UTC](https://discourse.ats-lang.org/t/building-on-cygwin-64-undefined-reference-to-winmain/339/2 "2014-09-26T18:11:02Z")

</div>

Sorry for the delayed reply; I started looking at it again and you are  
correct. In fact, the file I had peaked at previously (atscc\_main\_dats.c ) was  
the only one that had any code in it. The others ( atscc\_print\_dats.c,  
patscc\_dats.c ) are empty.On Sunday, September 21, 2014 12:18:36 AM UTC-4, gmhwxi wrote:

> patscc.dats contains an implementation of ‘main’.  
> I suspect that patscc\_dats.c was not properly generated (which might be  
> empty).
> 
> On Sat, Sep 20, 2014 at 10:00 PM, Brandon Barker \<[brand...@gmail.com](mailto:brand...@gmail.com) \<javascript:\>\> wrote:
> 
> > This is after a fresh rebuilt of ATS1 and ATS2:
> > 
> > cp -f src/patsopt bin/patsopt  
> > make -C utils/atscc -f Makefile all  
> > make[1]: Entering directory ‘/home/brand\_000/ATS-Postiats/utils/atscc’  
> >   
> > gcc -I"/home/brand\_000/ATS-Postiats"  
> > -I"/home/brand\_000/ATS-Postiats"/ccomp/runtime -std=c99 -D\_XOPEN\_SOURCE  
> > -DATS\_MEMALLOC\_LIBC -O2 -o patscc patscc\_dats.c atscc\_main\_dats.c  
> > atscc\_print\_dats.c  
> > /usr/lib/gcc/x86\_64-pc-cygwin/4.8.3/…/…/…/…/lib/libcygwin.a(libcmain.o):  
> > In function `main': /usr/src/debug/cygwin-1.7.32-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain’  
> > /usr/src/debug/cygwin-1.7.32-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  
> > Makefile:29: recipe for target ‘patscc’ failed  
> > make[1]: \*\*\* [patscc] Error 1  
> > make[1]: Leaving directory ‘/home/brand\_000/ATS-Postiats/utils/atscc’  
> > Makefile\_devl:39: recipe for target ‘src\_patscc’ failed  
> > make: \*\*\* [src\_patscc] Error 2
> > 
> > My only clue so far is that none of the \*.c files being compiled seem to  
> > include a main entry point, and this may be confusing cygwin’s linker.
> > 
> > –  
> > You received this message because you are subscribed to the Google Groups  
> > “ats-lang-users” group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [ats-lang...@googlegroups.com](mailto:ats-lang...@googlegroups.com) \<javascript:\>.  
> > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com)  
> > \<javascript:\>.  
> > Visit this group at [http://groups.google.com/group/ats-lang-users](http://groups.google.com/group/ats-lang-users).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .

---

<div class="post-metadata">

### Author: ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)
#### Post date: [September 26, 2014, 8:20pm UTC](https://discourse.ats-lang.org/t/building-on-cygwin-64-undefined-reference-to-winmain/339/3 "2014-09-26T20:20:33Z")

</div>

I’m actually getting this behavior on Linux as well. I’ll look in to it a  
bit more and submit an issue on github.On Friday, September 26, 2014 2:17:48 PM UTC-4, Brandon Barker wrote:

> In /home/brand\_000/ATS-Postiats/utils/atscc, doing:
> 
> rm \*.c  
> make
> 
> fixed the problem.
> 
> On Friday, September 26, 2014 2:11:02 PM UTC-4, Brandon Barker wrote:
> 
> > Sorry for the delayed reply; I started looking at it again and you are  
> > correct. In fact, the file I had peaked at previously (  
> > atscc\_main\_dats.c ) was the only one that had any code in it. The others  
> > ( atscc\_print\_dats.c, patscc\_dats.c ) are empty.
> > 
> > On Sunday, September 21, 2014 12:18:36 AM UTC-4, gmhwxi wrote:
> > 
> > > patscc.dats contains an implementation of ‘main’.  
> > > I suspect that patscc\_dats.c was not properly generated (which might be  
> > > empty).
> > > 
> > > On Sat, Sep 20, 2014 at 10:00 PM, Brandon Barker [brand...@gmail.com](mailto:brand...@gmail.com) wrote:
> > > 
> > > > This is after a fresh rebuilt of ATS1 and ATS2:
> > > > 
> > > > cp -f src/patsopt bin/patsopt  
> > > > make -C utils/atscc -f Makefile all  
> > > > make[1]: Entering directory ‘/home/brand\_000/ATS-Postiats/utils/atscc’  
> > > >   
> > > > gcc -I"/home/brand\_000/ATS-Postiats"  
> > > > -I"/home/brand\_000/ATS-Postiats"/ccomp/runtime -std=c99 -D\_XOPEN\_SOURCE  
> > > > -DATS\_MEMALLOC\_LIBC -O2 -o patscc patscc\_dats.c atscc\_main\_dats.c  
> > > > atscc\_print\_dats.c  
> > > > /usr/lib/gcc/x86\_64-pc-cygwin/4.8.3/…/…/…/…/lib/libcygwin.a(libcmain.o):  
> > > > In function `main': /usr/src/debug/cygwin-1.7.32-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain’  
> > > > /usr/src/debug/cygwin-1.7.32-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  
> > > > Makefile:29: recipe for target ‘patscc’ failed  
> > > > make[1]: \*\*\* [patscc] Error 1  
> > > > make[1]: Leaving directory ‘/home/brand\_000/ATS-Postiats/utils/atscc’  
> > > > Makefile\_devl:39: recipe for target ‘src\_patscc’ failed  
> > > > make: \*\*\* [src\_patscc] Error 2
> > > > 
> > > > My only clue so far is that none of the \*.c files being compiled seem  
> > > > to include a main entry point, and this may be confusing cygwin’s linker.
> > > > 
> > > > –  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups “ats-lang-users” group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [ats-lang...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).  
> > > > Visit this group at [http://groups.google.com/group/ats-lang-users](http://groups.google.com/group/ats-lang-users).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .

---

<div class="post-metadata">

### Author: ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)
#### Post date: [September 26, 2014, 6:17pm UTC](https://discourse.ats-lang.org/t/building-on-cygwin-64-undefined-reference-to-winmain/339/4 "2014-09-26T18:17:48Z")

</div>

In /home/brand\_000/ATS-Postiats/utils/atscc, doing:

rm \*.c  
make

fixed the problem.On Friday, September 26, 2014 2:11:02 PM UTC-4, Brandon Barker wrote:

> Sorry for the delayed reply; I started looking at it again and you are  
> correct. In fact, the file I had peaked at previously (  
> atscc\_main\_dats.c ) was the only one that had any code in it. The others  
> ( atscc\_print\_dats.c, patscc\_dats.c ) are empty.
> 
> On Sunday, September 21, 2014 12:18:36 AM UTC-4, gmhwxi wrote:
> 
> > patscc.dats contains an implementation of ‘main’.  
> > I suspect that patscc\_dats.c was not properly generated (which might be  
> > empty).
> > 
> > On Sat, Sep 20, 2014 at 10:00 PM, Brandon Barker [brand...@gmail.com](mailto:brand...@gmail.com) wrote:
> > 
> > > This is after a fresh rebuilt of ATS1 and ATS2:
> > > 
> > > cp -f src/patsopt bin/patsopt  
> > > make -C utils/atscc -f Makefile all  
> > > make[1]: Entering directory ‘/home/brand\_000/ATS-Postiats/utils/atscc’  
> > >   
> > > gcc -I"/home/brand\_000/ATS-Postiats"  
> > > -I"/home/brand\_000/ATS-Postiats"/ccomp/runtime -std=c99 -D\_XOPEN\_SOURCE  
> > > -DATS\_MEMALLOC\_LIBC -O2 -o patscc patscc\_dats.c atscc\_main\_dats.c  
> > > atscc\_print\_dats.c  
> > > /usr/lib/gcc/x86\_64-pc-cygwin/4.8.3/…/…/…/…/lib/libcygwin.a(libcmain.o):  
> > > In function `main': /usr/src/debug/cygwin-1.7.32-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain’  
> > > /usr/src/debug/cygwin-1.7.32-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  
> > > Makefile:29: recipe for target ‘patscc’ failed  
> > > make[1]: \*\*\* [patscc] Error 1  
> > > make[1]: Leaving directory ‘/home/brand\_000/ATS-Postiats/utils/atscc’  
> > > Makefile\_devl:39: recipe for target ‘src\_patscc’ failed  
> > > make: \*\*\* [src\_patscc] Error 2
> > > 
> > > My only clue so far is that none of the \*.c files being compiled seem to  
> > > include a main entry point, and this may be confusing cygwin’s linker.
> > > 
> > > –  
> > > You received this message because you are subscribed to the Google  
> > > Groups “ats-lang-users” group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [ats-lang...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).  
> > > Visit this group at [http://groups.google.com/group/ats-lang-users](http://groups.google.com/group/ats-lang-users).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .

---

<div class="post-metadata">

### Author: ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)
#### Post date: [September 21, 2014, 4:18am UTC](https://discourse.ats-lang.org/t/building-on-cygwin-64-undefined-reference-to-winmain/339/5 "2014-09-21T04:18:35Z")

</div>

patscc.dats contains an implementation of ‘main’.  
I suspect that patscc\_dats.c was not properly generated (which might be  
empty).On Sat, Sep 20, 2014 at 10:00 PM, Brandon Barker [brandon...@gmail.com](mailto:brandon...@gmail.com) wrote:

> This is after a fresh rebuilt of ATS1 and ATS2:
> 
> cp -f src/patsopt bin/patsopt  
> make -C utils/atscc -f Makefile all  
> make[1]: Entering directory ‘/home/brand\_000/ATS-Postiats/utils/atscc’  
>   
> gcc -I"/home/brand\_000/ATS-Postiats"  
> -I"/home/brand\_000/ATS-Postiats"/ccomp/runtime -std=c99 -D\_XOPEN\_SOURCE  
> -DATS\_MEMALLOC\_LIBC -O2 -o patscc patscc\_dats.c atscc\_main\_dats.c  
> atscc\_print\_dats.c  
> /usr/lib/gcc/x86\_64-pc-cygwin/4.8.3/…/…/…/…/lib/libcygwin.a(libcmain.o):  
> In function `main': /usr/src/debug/cygwin-1.7.32-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain’  
> /usr/src/debug/cygwin-1.7.32-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  
> Makefile:29: recipe for target ‘patscc’ failed  
> make[1]: \*\*\* [patscc] Error 1  
> make[1]: Leaving directory ‘/home/brand\_000/ATS-Postiats/utils/atscc’  
> Makefile\_devl:39: recipe for target ‘src\_patscc’ failed  
> make: \*\*\* [src\_patscc] Error 2
> 
> My only clue so far is that none of the \*.c files being compiled seem to  
> include a main entry point, and this may be confusing cygwin’s linker.
> 
> –  
> You received this message because you are subscribed to the Google Groups  
> “ats-lang-users” group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [ats-lang-user...@googlegroups.com](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> Visit this group at [http://groups.google.com/group/ats-lang-users](http://groups.google.com/group/ats-lang-users).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com)  
> [https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/df437625-13ee-4d10-bf24-299f52507b4b%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
