<?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>Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/25134/using-c-standard-libraries</link><description>I am using C++ to program the nRF52 DK and I am trying to use the standard vector library. 
 When I try and compile it I get the linker error:
${GCC_PATH}/arm-none-eabi/include/c++/6.3.1/ext/new_allocator.h:104: undefined reference to `operator new</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 24 Nov 2021 19:32:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/25134/using-c-standard-libraries" /><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/340608?ContentTypeID=1</link><pubDate>Wed, 24 Nov 2021 19:32:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a197203b-74cf-491d-a05d-fb72d6652a50</guid><dc:creator>Felix41382</dc:creator><description>&lt;p&gt;With SDK v1.7.0 I had to add:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;target_link_libraries(app PRIVATE
	stdc++
	)
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/272131?ContentTypeID=1</link><pubDate>Tue, 29 Sep 2020 16:45:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7658eac1-4c1d-4507-88b3-479c0c0423d4</guid><dc:creator>KevinG</dc:creator><description>&lt;p&gt;I can confirm this does indeed fix the problem.&amp;nbsp; Simply added it to the Makefile:&lt;/p&gt;
&lt;div&gt;
&lt;p&gt;&lt;code&gt;# Libraries common to all targets&lt;/code&gt;&lt;br /&gt;&lt;code&gt;LIB_FILES += -lstdc++ \&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Thanks Trish!&lt;br /&gt;&lt;br /&gt;-KevinG&lt;/p&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/99003?ContentTypeID=1</link><pubDate>Wed, 25 Oct 2017 04:43:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6d86470-57e0-4b1d-ace0-e33b0f98bc2b</guid><dc:creator>trish</dc:creator><description>&lt;p&gt;I solved this by adding -lstdc++ to lib files in the makefile, making sure lib files was in the makefile before linker flags&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/99001?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 20:34:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f802fb43-9680-40d5-972c-6dfcde4ceb51</guid><dc:creator>trish</dc:creator><description>&lt;p&gt;Jorgen - can you post a link to the makefile and main.ccp you were able to compile? I am having the same issue, cannot get stdlib to link&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/98999?ContentTypeID=1</link><pubDate>Tue, 19 Sep 2017 20:43:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66e25725-f95b-47c7-885e-4cab2f76f80c</guid><dc:creator>ishgum</dc:creator><description>&lt;p&gt;I&amp;#39;m definitely compiling as C++ as I am using classes etc in the files.
Did you try actually creating a vector object? I can include the library but I get these errors when I try to make a vector.&lt;/p&gt;
&lt;p&gt;I am using SDK 13.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/99000?ContentTypeID=1</link><pubDate>Tue, 19 Sep 2017 14:14:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3fb1e6f4-80a2-4363-8568-ffaf0ad1f232</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Are you sure you are compiling the file as C++? I tested adding the STL vector library to a project in SDK 14 and changed the main.c file into main.cpp (and changed this in the Makefile as well). I see no issues with compiling the file. Which SDK version are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/98998?ContentTypeID=1</link><pubDate>Mon, 18 Sep 2017 02:12:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:788235c2-6ba2-4a1c-9891-3b70ea9a29d9</guid><dc:creator>ishgum</dc:creator><description>&lt;p&gt;That got rid of those errors but replaces it with an undefined reference to &amp;#39;__cxa_begin_catch&amp;#39; and some other similar ones. Here is the terminal output:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/Users/michaelmcadam/SDK/Nordic_nf52/gcc-arm-none-eabi-6.3.1/arm-none-eabi/include/c++/6.3.1/bits/vector.tcc:427: undefined reference to `__cxa_begin_catch&amp;#39;
/Users/michaelmcadam/SDK/Nordic_nf52/gcc-arm-none-eabi-6.3.1/arm-none-eabi/include/c++/6.3.1/bits/vector.tcc:434: undefined reference to `__cxa_rethrow&amp;#39;
/Users/michaelmcadam/SDK/Nordic_nf52/gcc-arm-none-eabi-6.3.1/arm-none-eabi/include/c++/6.3.1/bits/vector.tcc:427: undefined reference to `__cxa_end_catch&amp;#39;
/Users/michaelmcadam/SDK/Nordic_nf52/gcc-arm-none-eabi-6.3.1/arm-none-eabi/include/c++/6.3.1/bits/vector.tcc:427: undefined reference to `__cxa_end_cleanup&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/98996?ContentTypeID=1</link><pubDate>Fri, 15 Sep 2017 13:51:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e22cca0d-3d61-4508-a786-bb642fed6794</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;How about &lt;a href="https://devzone.nordicsemi.com/question/131290/undefined-reference-to-operator-newunsigned-int/"&gt;this suggestion&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/98995?ContentTypeID=1</link><pubDate>Thu, 14 Sep 2017 21:06:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d560388-0ee9-4ca3-a75f-ccc161cbcfe3</guid><dc:creator>ishgum</dc:creator><description>&lt;p&gt;I set the -std=c++11 flag under CXXFLAGS to no effect. I also tried adding the linker flag -lstdc++ under LDFLAGS to no effect.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/99002?ContentTypeID=1</link><pubDate>Thu, 14 Sep 2017 12:51:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2523153f-d875-4c89-a842-9e2d3d322a25</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Another user had some &lt;a href="https://devzone.nordicsemi.com/question/114169/undefined-reference-to-operator-delete-using-segger-embedded-studio/?comment=114752#comment-114752"&gt;similar issues when using Segger Embedded Studio&lt;/a&gt;. These were solved by setting the C++ standard to C++11. Could you try setting the flag &lt;code&gt;-std=c++11&lt;/code&gt; in your Makefile/GCC compilation?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/98997?ContentTypeID=1</link><pubDate>Wed, 13 Sep 2017 21:03:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50932a1c-3ca1-428a-b549-c8f0d041bf19</guid><dc:creator>ishgum</dc:creator><description>&lt;p&gt;I am using GCC as my compiler, although my understanding is that it will automatically use the g++ compiler when working with a cpp file? (For reference, I have other .cpp files which are compiling fine, just can&amp;#39;t use stdc++).&lt;/p&gt;
&lt;p&gt;I tried passing the following:&lt;/p&gt;
&lt;p&gt;CPPFLAGS += -I/${GCC_PATH}/arm-none-eabi/include
LDFLAGS += -L/${GCC_PATH}/arm-none-eabi/lib
LDLIBS += -lstdc++&lt;/p&gt;
&lt;p&gt;But this ending up giving a massive amount of errors, so I figured it was the wrong direction.&lt;/p&gt;
&lt;p&gt;Thanks for your help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ standard libraries</title><link>https://devzone.nordicsemi.com/thread/98994?ContentTypeID=1</link><pubDate>Wed, 13 Sep 2017 11:38:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17f0efa8-5bdc-482c-919d-dc60d1921485</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Which compiler are you using, and what flags are you passing to the compiler?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>