# Error while compiling the example "twice.dats"

**URL:** <https://discourse.ats-lang.org/t/error-while-compiling-the-example-twice-dats/375>\
**Category:** Google Group\
**Created:** [February 12, 2014, 8:05pm UTC](https://discourse.ats-lang.org/t/error-while-compiling-the-example-twice-dats/375 "2014-02-12T20:05:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shahab\_Tasharrofi](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@Shahab\_Tasharrofi](https://discourse.ats-lang.org/u/Shahab_Tasharrofi)\
**Post date:** [February 12, 2014, 8:05pm UTC](https://discourse.ats-lang.org/t/error-while-compiling-the-example-twice-dats/375/1 "2014-02-12T20:05:16Z")

</div>

Hello,

I’m just trying to warm myself up with ATS and I’m going through the online  
tutorial here:  
[http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/index.html](http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/index.html)

However, while trying to compile the “twice.dats” example using the  
command “patscc twice.dats”, I get a compilation error that says “undefined  
reference to `atsruntime\_malloc\_undef’” (several times).

Here is the link to “twice.dats” that I have been using:  
[http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/CODE/CHAP\_FUNCTION/twice.dats](http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/CODE/CHAP_FUNCTION/twice.dats)

And, here’s the output of running “patscc --version”:

exec(patsopt --version)  
Hello from ATS2(ATS/Postiats)!  
ATS/Postiats version 0.0.5 with Copyright © 2011-2013 Hongwei Xi  
exec(patsopt --version) = 0  
exec(gcc -std=c99 -D\_XOPEN\_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime  
-L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64 --version)  
gcc (GCC) 4.8.2 20131212 (Red Hat 4.8.2-7)  
Copyright © 2013 Free Software Foundation, Inc.  
This is free software; see the source for copying conditions. There is NO  
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

exec(gcc -std=c99 -D\_XOPEN\_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime  
-L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64 --version) =  
0

Am I missing something? Should I be using another command (a similar  
command has been working on previous examples)? Is there a problem with  
my installation of ATS?

Thanks,  
Shahab

---

<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:** [February 12, 2014, 8:43pm UTC](https://discourse.ats-lang.org/t/error-while-compiling-the-example-twice-dats/375/2 "2014-02-12T20:43:10Z")

</div>

I also want to point out that there is a Makefile for each chapter.  
For instance,

[http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/CODE/CHAP\_FUNCTION/Makefile](http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/CODE/CHAP_FUNCTION/Makefile)

You can read the Makefile to see how an example can be compiled.On Wednesday, February 12, 2014 3:23:38 PM UTC-5, gmhwxi wrote:

> If you want to run garbage collection, you can use -DATS\_MEMALLOC\_GCBDW.  
> If you do, you need libgc by Hans Bohem.
> 
> On Wednesday, February 12, 2014 3:08:52 PM UTC-5, Brandon Barker wrote:
> 
> > I just ran in to this one yesterday, you need the -DATS\_MEMALLOC\_LIBC  
> > flag.
> > 
> > [ats2-lang / Wiki / compiler errors](http://sourceforge.net/p/ats2-lang/wiki/compiler%20errors/)
> > 
> > On Wednesday, February 12, 2014 3:05:16 PM UTC-5, Shahab Tasharrofi wrote:
> > 
> > > Hello,
> > > 
> > > I’m just trying to warm myself up with ATS and I’m going through the  
> > > online  
> > > tutorial here:  
> > > [http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/index.html](http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/index.html)
> > > 
> > > However, while trying to compile the “twice.dats” example using the  
> > > command “patscc twice.dats”, I get a compilation error that says  
> > > “undefined  
> > > reference to `atsruntime\_malloc\_undef’” (several times).
> > > 
> > > Here is the link to “twice.dats” that I have been using:
> > > 
> > > [http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/CODE/CHAP\_FUNCTION/twice.dats](http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/CODE/CHAP_FUNCTION/twice.dats)
> > > 
> > > And, here’s the output of running “patscc --version”:
> > > 
> > > exec(patsopt --version)  
> > > Hello from ATS2(ATS/Postiats)!  
> > > ATS/Postiats version 0.0.5 with Copyright (c) 2011-2013 Hongwei Xi  
> > > exec(patsopt --version) = 0  
> > > exec(gcc -std=c99 -D\_XOPEN\_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime  
> > > -L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64 –  
> > > version)  
> > > gcc (GCC) 4.8.2 20131212 (Red Hat 4.8.2-7)  
> > > Copyright (C) 2013 Free Software Foundation, Inc.  
> > > This is free software; see the source for copying conditions. There isNO  
> > > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR  
> > > PURPOSE.
> > > 
> > > exec(gcc -std=c99 -D\_XOPEN\_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime  
> > > -L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64 –  
> > > version) = 0
> > > 
> > > Am I missing something? Should I be using another command (a similar  
> > > command has been working on previous examples)? Is there a problem with  
> > > my installation of ATS?
> > > 
> > > Thanks,  
> > > Shahab

---

<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:** [February 12, 2014, 8:23pm UTC](https://discourse.ats-lang.org/t/error-while-compiling-the-example-twice-dats/375/3 "2014-02-12T20:23:38Z")

</div>

If you want to run garbage collection, you can use -DATS\_MEMALLOC\_GCBDW.  
If you do, you need libgc by Hans Bohem.On Wednesday, February 12, 2014 3:08:52 PM UTC-5, Brandon Barker wrote:

> I just ran in to this one yesterday, you need the -DATS\_MEMALLOC\_LIBC flag.
> 
> [ats2-lang / Wiki / compiler errors](http://sourceforge.net/p/ats2-lang/wiki/compiler%20errors/)
> 
> On Wednesday, February 12, 2014 3:05:16 PM UTC-5, Shahab Tasharrofi wrote:
> 
> > Hello,
> > 
> > I’m just trying to warm myself up with ATS and I’m going through the  
> > online  
> > tutorial here:  
> > [http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/index.html](http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/index.html)
> > 
> > However, while trying to compile the “twice.dats” example using the  
> > command “patscc twice.dats”, I get a compilation error that says  
> > “undefined  
> > reference to `atsruntime\_malloc\_undef’” (several times).
> > 
> > Here is the link to “twice.dats” that I have been using:
> > 
> > [http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/CODE/CHAP\_FUNCTION/twice.dats](http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/CODE/CHAP_FUNCTION/twice.dats)
> > 
> > And, here’s the output of running “patscc --version”:
> > 
> > exec(patsopt --version)  
> > Hello from ATS2(ATS/Postiats)!  
> > ATS/Postiats version 0.0.5 with Copyright (c) 2011-2013 Hongwei Xi  
> > exec(patsopt --version) = 0  
> > exec(gcc -std=c99 -D\_XOPEN\_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime  
> > -L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64 --version  
> > )  
> > gcc (GCC) 4.8.2 20131212 (Red Hat 4.8.2-7)  
> > Copyright (C) 2013 Free Software Foundation, Inc.  
> > This is free software; see the source for copying conditions. There is NO  
> > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR  
> > PURPOSE.
> > 
> > exec(gcc -std=c99 -D\_XOPEN\_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime  
> > -L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64 --version  
> > ) = 0
> > 
> > Am I missing something? Should I be using another command (a similar  
> > command has been working on previous examples)? Is there a problem with  
> > my installation of ATS?
> > 
> > Thanks,  
> > Shahab

---

<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:** [February 12, 2014, 8:08pm UTC](https://discourse.ats-lang.org/t/error-while-compiling-the-example-twice-dats/375/4 "2014-02-12T20:08:52Z")

</div>

I just ran in to this one yesterday, you need the -DATS\_MEMALLOC\_LIBC flag.

[http://sourceforge.net/p/ats2-lang/wiki/compiler%20errors/On](http://sourceforge.net/p/ats2-lang/wiki/compiler%20errors/On) Wednesday, February 12, 2014 3:05:16 PM UTC-5, Shahab Tasharrofi wrote:

> Hello,
> 
> I’m just trying to warm myself up with ATS and I’m going through the online  
> tutorial here:  
> [http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/index.html](http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/index.html)
> 
> However, while trying to compile the “twice.dats” example using the  
> command “patscc twice.dats”, I get a compilation error that says “undefined  
> reference to `atsruntime\_malloc\_undef’” (several times).
> 
> Here is the link to “twice.dats” that I have been using:
> 
> [http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/CODE/CHAP\_FUNCTION/twice.dats](http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/CODE/CHAP_FUNCTION/twice.dats)
> 
> And, here’s the output of running “patscc --version”:
> 
> exec(patsopt --version)  
> Hello from ATS2(ATS/Postiats)!  
> ATS/Postiats version 0.0.5 with Copyright (c) 2011-2013 Hongwei Xi  
> exec(patsopt --version) = 0  
> exec(gcc -std=c99 -D\_XOPEN\_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime  
> -L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64 --version)  
> gcc (GCC) 4.8.2 20131212 (Red Hat 4.8.2-7)  
> Copyright (C) 2013 Free Software Foundation, Inc.  
> This is free software; see the source for copying conditions. There is NO  
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE  
> .
> 
> exec(gcc -std=c99 -D\_XOPEN\_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime  
> -L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64 --version)  
> = 0
> 
> Am I missing something? Should I be using another command (a similar  
> command has been working on previous examples)? Is there a problem with  
> my installation of ATS?
> 
> Thanks,  
> Shahab
