<?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>Undefined reference to &amp;#39;clock&amp;#39; after linking demo.elf</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42602/undefined-reference-to-clock-after-linking-demo-elf</link><description>Hi all, 
 I am sorry if this is a rookie question. I had researched and tried the methods shown online, including: 
 
 added $(ProjectDir)/flash_placement.xml to the linker section &amp;gt; section placement file of the project option 
 editing the sdk_config</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 16 Jan 2019 18:24:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42602/undefined-reference-to-clock-after-linking-demo-elf" /><item><title>RE: Undefined reference to 'clock' after linking demo.elf</title><link>https://devzone.nordicsemi.com/thread/166091?ContentTypeID=1</link><pubDate>Wed, 16 Jan 2019 18:24:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adf5a388-abf5-4c52-ba5a-7ae9148f1643</guid><dc:creator>awneil</dc:creator><description>[quote userid="75833" url="~/f/nordic-q-a/42602/undefined-reference-to-clock-after-linking-demo-elf/166064"]it worked fine[/quote]
&lt;p&gt;Excellent. Now please verify the answer:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/6052._5F00_Verify_2D00_answer_2D00_nordic.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undefined reference to 'clock' after linking demo.elf</title><link>https://devzone.nordicsemi.com/thread/166064?ContentTypeID=1</link><pubDate>Wed, 16 Jan 2019 16:09:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:522a49da-b324-4c03-aa61-e79fd88cd48b</guid><dc:creator>The Boon</dc:creator><description>&lt;p&gt;Hi awneil,&lt;/p&gt;
&lt;p&gt;Thank you for your reply. Thank you for the tips for posting source code, that would be very helpful in the future!&lt;/p&gt;
&lt;p&gt;I had just found out online that embedded studio used to program the firmware is a &lt;strong&gt;freestanding embedded environment&lt;/strong&gt; that does not support the standard C library, as someone had the same problem using clock() for other microcontroller. So the problem will arise during linking. Clock() is incorrect for the case of an embedded controller as it measures processor time taken for CPU. I have used the time elapsed after enabling Timer 0 and it worked fine.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undefined reference to 'clock' after linking demo.elf</title><link>https://devzone.nordicsemi.com/thread/166017?ContentTypeID=1</link><pubDate>Wed, 16 Jan 2019 14:16:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97480cfe-01da-457a-9dcb-5a99b451b3a1</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;You make a call to the function &lt;strong&gt;clock():&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;t_latency_stop = clock();&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But the linker is telling you that it cannot find any definition of that function.&lt;/p&gt;
&lt;p&gt;Usually this happens because you&amp;#39;ve #included a header (&lt;strong&gt;.h&lt;/strong&gt;) file which just&amp;nbsp;&lt;em&gt;declares&lt;/em&gt; the function - but nothing which &lt;em&gt;&lt;strong&gt;defines&lt;/strong&gt;&lt;/em&gt; it.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://c-faq.com/decl/decldef.html"&gt;c-faq.com/.../decldef.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So you need to provide that definition - either is a &amp;#39;C&amp;#39; source file (&lt;strong&gt;.c&lt;/strong&gt;), or as a prebuilt library.&lt;/p&gt;
&lt;p&gt;This is standard &amp;#39;C&amp;#39; stuff - not specific to Nordic.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How to properly post source code:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/4670._5F00_Insert-Code-_2D00_-Nordic.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;EDIT&lt;/p&gt;
&lt;p&gt;Specific to the Nordic SDK, you also have to make sure that the features are enbaled in the &lt;strong&gt;sdk_config.h&lt;/strong&gt; file:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/39503/undefined-reference-on-the-linker-level/153004#153004"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/39503/undefined-reference-on-the-linker-level/153004#153004&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>