<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>about the  link error with arm-none-eabi on the eclipse environment.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/440/about-the-link-error-with-arm-none-eabi-on-the-eclipse-environment</link><description>Hello all 
 I&amp;#39;m struggling with link errors, &amp;quot;undefined referencce atan2&amp;quot; as well as all math library.
I still dont know why it is occurred these errors.
I configured the eclipse compile environment with the gnu arm tool using your doc, application</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 06 Jan 2016 14:37:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/440/about-the-link-error-with-arm-none-eabi-on-the-eclipse-environment" /><item><title>RE: about the  link error with arm-none-eabi on the eclipse environment.</title><link>https://devzone.nordicsemi.com/thread/2274?ContentTypeID=1</link><pubDate>Wed, 06 Jan 2016 14:37:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5813dd96-28e3-4f26-afbd-9049b5e384b2</guid><dc:creator>Raphael</dc:creator><description>&lt;p&gt;Worked just fine with LD as a linker command for me (ARM GCC 4.9.3). See my answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: about the  link error with arm-none-eabi on the eclipse environment.</title><link>https://devzone.nordicsemi.com/thread/2275?ContentTypeID=1</link><pubDate>Wed, 06 Jan 2016 14:36:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f86a913b-8a74-4985-a9aa-20d7d2d2727e</guid><dc:creator>Raphael</dc:creator><description>&lt;p&gt;You need to tell the linker to actually link in the math library (libm). The header include only includes the declaration, but then of course at link time the code won&amp;#39;t be included if you don&amp;#39;t tell the linker. Different than the C standard library, math.h constitutes an additional library &lt;a href="https://stackoverflow.com/questions/1033898/why-do-you-have-to-link-the-math-library-in-c"&gt;which the linker won&amp;#39;t include by default&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you are using a makefile that is based on Nordic&amp;#39;s GCC / GNU make makefile, simply add&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;LIBS = -lm&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;LIBS += -lm&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;in your makefile.&lt;/p&gt;
&lt;p&gt;The example makefile from Nordic does include $(LIBS) in the targets, but LIBS is never defined. You of course need to use the second variant if you defined LIBS yourself.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: about the  link error with arm-none-eabi on the eclipse environment.</title><link>https://devzone.nordicsemi.com/thread/2272?ContentTypeID=1</link><pubDate>Wed, 22 Apr 2015 10:42:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:994ca7d5-f1b4-48cd-8870-b5493de382ba</guid><dc:creator>maxpaynner</dc:creator><description>&lt;p&gt;This works&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: about the  link error with arm-none-eabi on the eclipse environment.</title><link>https://devzone.nordicsemi.com/thread/2273?ContentTypeID=1</link><pubDate>Sat, 18 Apr 2015 16:33:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5d3fb73-89ae-4b1d-aaff-8163b4e81c5e</guid><dc:creator>maxpaynner</dc:creator><description>&lt;p&gt;I had this same problem.&lt;/p&gt;
&lt;p&gt;The solution was:&lt;/p&gt;
&lt;p&gt;1- Link with GCC instead of LD (some guys recommend this, dunno where I read it, but seems to work). In your makefile replace&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;LD       		:= &amp;quot;$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ld&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;LD       		:= &amp;quot;$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-gcc&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;2- Manually add the math lib to your libs&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#link math library.. dunno why this isn&amp;#39;t done automatically

LIBS += $(GNU_INSTALL_ROOT)/arm-none-eabi/lib/thumb/libm.a
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I don&amp;#39;t know why the linker doesn&amp;#39;t automatically link the library but this seemed to work for me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: about the  link error with arm-none-eabi on the eclipse environment.</title><link>https://devzone.nordicsemi.com/thread/2271?ContentTypeID=1</link><pubDate>Mon, 16 Dec 2013 16:39:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9175bc2-1233-4cde-8ced-4cafc0f0c535</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;You&amp;#39;re right, I see the same when I tried this modification. To make it work, I had to add -lm to the linking command line. Beware that the place in the line actually matters, but things seemed to work when I put it right before the -o parameter in the final linking:
$(CC) $(LDFLAGS) $(C_OBJECTS) $(ASSEMBLER_OBJECTS) $(LIBRARIES) -lm -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: about the  link error with arm-none-eabi on the eclipse environment.</title><link>https://devzone.nordicsemi.com/thread/2270?ContentTypeID=1</link><pubDate>Tue, 10 Dec 2013 18:08:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6406ec51-18e9-40be-916f-1b4ac2be9894</guid><dc:creator>Markus Roppelt</dc:creator><description>&lt;p&gt;I can compile the attached math-lib.zip. However if I change the the argument to a variable I get following error.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;main.c:(.text.startup+0x5a): undefined reference to `atan2&amp;#39;
collect2.exe: error: ld returned 1 exit status
make: *** [_build/template_project_gcc_s110_xxaa.out] Fehler 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My main is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
int main(void)
{	
	uint8_t idx = 0;
	double d_idx = 0.0;
	uint8_t buffer[20];
	simple_uart_config(0, 17, 0, 16, false);
	simple_uart_putstring((uint8_t *)&amp;quot;Start\r\n&amp;quot;);
	nrf_gpio_range_cfg_output(8, 15);
	
	while (true)
    {
		idx++;
		d_idx = (double) idx;
		float result = atan2(1.0, d_idx);
		sprintf((char *)buffer, &amp;quot;%f\r\n&amp;quot;, result);
		simple_uart_putstring(buffer);
		nrf_delay_us(100000);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;How can I build this?&lt;/p&gt;
&lt;p&gt;Greetings
Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: about the  link error with arm-none-eabi on the eclipse environment.</title><link>https://devzone.nordicsemi.com/thread/2269?ContentTypeID=1</link><pubDate>Fri, 13 Sep 2013 11:53:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be6b4e8f-20d2-4929-8a80-0a16a32664b6</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;As far as I can see, this just works out of the box. Please see the attached example, that should compile directly if you put it in the Board/nrf6310/ folder, both with SDK version 4.3.0 and 4.4.0. If you still struggle, could you please upload your complete project, including any Makefiles and linker scripts?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/math_2D00_lib.zip"&gt;math-lib.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>