<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Linker error &amp;quot;Undefined reference to 'xxx' &amp;quot; in LPCXpresso IDE FAQs</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Linker-error-quot-Undefined-reference-to-xxx-quot/m-p/472216#M84</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The simplest reason for seeing undefined references when linking is that there is a problem with your own code base. For example, you may have misspelt the name of one of the functions that you call, or you may not have linked in a library project. However a very common reason for such errors is that you are linking with the wrong C library variant!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you linking against the Newlib(none) or Redlib(none) C library variants and are using functions from the C library such as &lt;TT&gt;printf&lt;/TT&gt; or &lt;TT&gt;malloc&lt;/TT&gt; you will get errors about undefined references when linking. Fuller examples of these error messages can be seen lower down this FAQ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In such circumstances you will need to change which variant of the C library you are linking:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Redlib: to resolve the the undefined references, use:&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Redlib(nohost)&lt;/STRONG&gt;, or&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Redlib(semihost)&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Newlib: to resolve the the undefined references, use:&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Newlib(nohost)&lt;/STRONG&gt;, or&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Newlib(semihost)&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Details of how to do this can be found in the FAQ "&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389104" data-objecttype="1" href="https://community.nxp.com/thread/389104" rel="nofollow noopener noreferrer" target="_blank"&gt;Switching the selected C library&lt;/A&gt;".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For an explanation of the library variants, please see the FAQ "&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389153" data-objecttype="1" href="https://community.nxp.com/thread/389153" rel="nofollow noopener noreferrer" target="_blank"&gt;What are none, nohost and semihost libraries?&lt;/A&gt;".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 id="toc-hId-1708365640" style="font-family: Lato, sans-serif; color: #e66e08; font-size: 18px; background: 0 50% #ffffff;"&gt;Undefined references with Redlib&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The below is an example set of errors encountered when linking an application that calls printf() using Redlib...&lt;/P&gt;&lt;PRE style="font-family: monospace, serif; font-size: 12px; color: #646464;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;In function `printf':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;fpprintf.c:(.text.printf+0x36): undefined reference to `__sys_write'&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;In function `__flsbuf':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;_deferredlazyseek.c:(.text.(float, long, short, bool, float __restrict)+0x92): 
undefined reference to `__sys_istty'&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;In function `_Cwritebuf':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;_writebuf.c:(.text._Cwritebuf+0x18): undefined reference to `__sys_flen'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;_writebuf.c:(.text._Cwritebuf+0x2e): undefined reference to `__sys_seek'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;_writebuf.c:(.text._Cwritebuf+0x56): undefined reference to `__sys_write'&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;In function `malloc':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;alloc.c:(.text.malloc+0x70): undefined reference to `_sbrk'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;alloc.c:(.text.malloc+0x92): undefined reference to `_sbrk'&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;In function `_Csys_alloc':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;alloc.c:(.text._Csys_alloc+0xe): undefined reference to `__sys_write'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;alloc.c:(.text._Csys_alloc+0x12): undefined reference to `__sys_appexit'&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;In function `fseek':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;fseek.c:(.text.fseek+0x1c): undefined reference to `__sys_istty'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;fseek.c:(.text.fseek+0x3e): undefined reference to `__sys_flen'&lt;/SPAN&gt;

&lt;/PRE&gt;&lt;H2 id="toc-hId--843791321" style="font-family: Lato, sans-serif; color: #e66e08; font-size: 18px; background: 0 50% #ffffff;"&gt;Undefined references with Newlib&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The below is an example set of errors encountered when linking an application that calls printf() using Newlib...&lt;/P&gt;&lt;PRE style="font-family: monospace, serif; font-size: 12px; color: #646464;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;In function `_sbrk_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;sbrkr.c:(.text+0xc): undefined reference to `_sbrk'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_write_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;writer.c:(.text+0x10): undefined reference to `_write'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_close_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;closer.c:(.text+0xc): undefined reference to `_close'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_fstat_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;fstatr.c:(.text+0xe): undefined reference to `_fstat'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_isatty_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;isattyr.c:(.text+0xc): undefined reference to `_isatty'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_lseek_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;lseekr.c:(.text+0x10): undefined reference to `_lseek'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_read_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;readr.c:(.text+0x10): undefined reference to `_read'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `abort':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;abort.c:(.text+0xa): undefined reference to `_exit'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_kill_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;signalr.c:(.text+0xe): undefined reference to `_kill'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_getpid_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;signalr.c:(.text+0x28): undefined reference to `_getpid'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Mar 2016 21:23:45 GMT</pubDate>
    <dc:creator>lpcware-support</dc:creator>
    <dc:date>2016-03-31T21:23:45Z</dc:date>
    <item>
      <title>Linker error "Undefined reference to 'xxx' "</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Linker-error-quot-Undefined-reference-to-xxx-quot/m-p/472216#M84</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The simplest reason for seeing undefined references when linking is that there is a problem with your own code base. For example, you may have misspelt the name of one of the functions that you call, or you may not have linked in a library project. However a very common reason for such errors is that you are linking with the wrong C library variant!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you linking against the Newlib(none) or Redlib(none) C library variants and are using functions from the C library such as &lt;TT&gt;printf&lt;/TT&gt; or &lt;TT&gt;malloc&lt;/TT&gt; you will get errors about undefined references when linking. Fuller examples of these error messages can be seen lower down this FAQ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In such circumstances you will need to change which variant of the C library you are linking:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Redlib: to resolve the the undefined references, use:&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Redlib(nohost)&lt;/STRONG&gt;, or&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Redlib(semihost)&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Newlib: to resolve the the undefined references, use:&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Newlib(nohost)&lt;/STRONG&gt;, or&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Newlib(semihost)&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Details of how to do this can be found in the FAQ "&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389104" data-objecttype="1" href="https://community.nxp.com/thread/389104" rel="nofollow noopener noreferrer" target="_blank"&gt;Switching the selected C library&lt;/A&gt;".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For an explanation of the library variants, please see the FAQ "&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389153" data-objecttype="1" href="https://community.nxp.com/thread/389153" rel="nofollow noopener noreferrer" target="_blank"&gt;What are none, nohost and semihost libraries?&lt;/A&gt;".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 id="toc-hId-1708365640" style="font-family: Lato, sans-serif; color: #e66e08; font-size: 18px; background: 0 50% #ffffff;"&gt;Undefined references with Redlib&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The below is an example set of errors encountered when linking an application that calls printf() using Redlib...&lt;/P&gt;&lt;PRE style="font-family: monospace, serif; font-size: 12px; color: #646464;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;In function `printf':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;fpprintf.c:(.text.printf+0x36): undefined reference to `__sys_write'&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;In function `__flsbuf':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;_deferredlazyseek.c:(.text.(float, long, short, bool, float __restrict)+0x92): 
undefined reference to `__sys_istty'&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;In function `_Cwritebuf':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;_writebuf.c:(.text._Cwritebuf+0x18): undefined reference to `__sys_flen'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;_writebuf.c:(.text._Cwritebuf+0x2e): undefined reference to `__sys_seek'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;_writebuf.c:(.text._Cwritebuf+0x56): undefined reference to `__sys_write'&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;In function `malloc':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;alloc.c:(.text.malloc+0x70): undefined reference to `_sbrk'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;alloc.c:(.text.malloc+0x92): undefined reference to `_sbrk'&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;In function `_Csys_alloc':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;alloc.c:(.text._Csys_alloc+0xe): undefined reference to `__sys_write'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;alloc.c:(.text._Csys_alloc+0x12): undefined reference to `__sys_appexit'&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;In function `fseek':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;fseek.c:(.text.fseek+0x1c): undefined reference to `__sys_istty'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;fseek.c:(.text.fseek+0x3e): undefined reference to `__sys_flen'&lt;/SPAN&gt;

&lt;/PRE&gt;&lt;H2 id="toc-hId--843791321" style="font-family: Lato, sans-serif; color: #e66e08; font-size: 18px; background: 0 50% #ffffff;"&gt;Undefined references with Newlib&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The below is an example set of errors encountered when linking an application that calls printf() using Newlib...&lt;/P&gt;&lt;PRE style="font-family: monospace, serif; font-size: 12px; color: #646464;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;In function `_sbrk_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;sbrkr.c:(.text+0xc): undefined reference to `_sbrk'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_write_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;writer.c:(.text+0x10): undefined reference to `_write'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_close_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;closer.c:(.text+0xc): undefined reference to `_close'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_fstat_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;fstatr.c:(.text+0xe): undefined reference to `_fstat'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_isatty_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;isattyr.c:(.text+0xc): undefined reference to `_isatty'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_lseek_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;lseekr.c:(.text+0x10): undefined reference to `_lseek'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_read_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;readr.c:(.text+0x10): undefined reference to `_read'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `abort':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;abort.c:(.text+0xa): undefined reference to `_exit'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_kill_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;signalr.c:(.text+0xe): undefined reference to `_kill'&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;In function `_getpid_r':&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;signalr.c:(.text+0x28): undefined reference to `_getpid'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2016 21:23:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Linker-error-quot-Undefined-reference-to-xxx-quot/m-p/472216#M84</guid>
      <dc:creator>lpcware-support</dc:creator>
      <dc:date>2016-03-31T21:23:45Z</dc:date>
    </item>
  </channel>
</rss>

