{"id":3339,"date":"2013-08-23T16:00:00","date_gmt":"2013-08-23T16:00:00","guid":{"rendered":"http:\/\/localhost:8105\/?p=3339"},"modified":"2021-12-04T22:55:42","modified_gmt":"2021-12-04T22:55:42","slug":"trying-out-gcc-4-8-0-on-ubuntu-13-04","status":"publish","type":"post","link":"https:\/\/blog.shahada.abubakar.net\/?p=3339","title":{"rendered":"Trying out gcc-4.8.0 on Ubuntu 13.04."},"content":{"rendered":"<div id=\"content\">\nTrying out gcc-4.8.0 on Ubuntu 13.04.<\/p>\n<p>gcc-4.8.0, which has the best &#8220;experimental support for C++ 11&#8221;, should be standard in the upcoming Ubuntu 13.10, but you can play around with it using a PPA:<\/p>\n<p>sudo add-apt-repository -y ppa:ubuntu-toolchain-r\/test<br \/>\nsudo apt-get update -y<br \/>\nsudo apt-get install g++-4.8<\/p>\n<p>The regular &#8220;gcc&#8221; and &#8220;g++&#8221; are still symlinked to gcc 4.7, &nbsp;so they get used by default.&nbsp;If you want 4.8 by default, do this:<\/p>\n<p>cd \/usr\/bin<br \/>\nsudo ln -sf g++-4.8 g++<br \/>\nsudo ln -sf gcc-4.8 gcc<br \/>\nsudo ln -sf gcov-4.8 gcov<\/p>\n<p>Revert with:<\/p>\n<p>cd \/usr\/bin<br \/>\nsudo ln -sf g++-4.7 g++<br \/>\nsudo ln -sf gcc-4.7 gcc<br \/>\nsudo ln -sf gcov-4.7 gcov<\/p>\n<p>To use it:<\/p>\n<p>g++&nbsp;-std=c++11 prog.cpp -o prog<\/p>\n<p>To get Eclipse to compile c++11 and also get the CDT to resolve C++ libraries, follow these steps from&nbsp;<a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/stackoverflow.com\/questions\/17457069\/enabling-c11-in-eclipse-kepler-cdt\" class=\"ot-anchor bidi_isolate\" jslog=\"10929; track:click\" dir=\"ltr\">http:\/\/stackoverflow.com\/questions\/17457069\/enabling-c11-in-eclipse-kepler-cdt<\/a>:<\/p>\n<p>There&#8217;s two things you have to do, first you need to setup your compiler, then you need to setup CDT&#8217;s language processor. Since you didn&#8217;t mention which compiler you&#8217;re using, I&#8217;ll assume it&#8217;s GCC but the steps will be similar for other compilers. (Note that you need a compiler that supports C++11, of course.)<\/p>\n<p>Setting up the compiler is fairly straightforward:<\/p>\n<p>* Right click your project and click Properties<br \/>\n* Under C\/C++ Build click Settings<br \/>\n* Under GCC C++ Compiler, click Miscellaneous<br \/>\n* In the Other Flags box, append &#8220;-std=c++11&#8221; to the list of tokens.<br \/>\n* Click Apply and OK<\/p>\n<p>At this point you should be able to rebuild your project and get it to run. But CDT still may show errors for C++11 includes. Here&#8217;s how you can resolve that:<\/p>\n<p>* Right click your project and click Properties<br \/>\n* Under C\/C++ General click &#8220;Preprocessor Include Paths, Macros&#8221;<br \/>\n* Select the Providers tab<br \/>\n* There should be an item in the list that says something like &#8220;CDT GCC Built in Compiler Settings&#8221;. Select this entry.<br \/>\n* Under the list there&#8217;s an box that says &#8220;Command to get compiler specs.&#8221; Append &#8220;-std=c++11&#8221; to this.<br \/>\n* Click Apply and then OK.<br \/>\n* Back in your Eclipse workspace, select the Project Menu, C\/C++ Index, and click &#8220;Re-resolve unresolved includes.&#8221;. You may also have to save and clean and do a full build.<\/p>\n<p>If you&#8217;re building stuff that uses std::threads, you may still need to link in the pthreads library:<\/p>\n<p>* Project -&gt; Properties -&gt; C\/C++ Build -&gt; Settings -&gt; Tool Settings<br \/>\n* GCC C++ Linker -&gt; Libraries -&gt; + -&gt; pthread -&gt; OK<\/p>\n<p><a rel=\"nofollow\" class=\"ot-hashtag bidi_isolate\" href=\"https:\/\/plus.google.com\/s\/%23C%2B%2B11\/posts\">#C++11<\/a><\/p>\n<hr>\n<p>LINK:<br \/>\n<a href=\"http:\/\/gcc.gnu.org\/projects\/cxx0x.html\"><br \/>\nC++0x\/C++11 Support in GCC &#8211; GNU Project &#8211; Free Software Foundation (FSF)<\/a><\/p>\n<p><i>This post was originally <a href=\"https:\/\/plus.google.com\/+shahadaabubakar\/posts\/ANHfNpjKcZe\">published<\/a> publicly on <a href=\"http:\/\/plus.google.com\">Google+<\/a> at 2013-08-24 02:38:17+0800<\/i><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Trying out gcc-4.8.0 on Ubuntu 13.04. gcc-4.8.0, which has the best &#8220;experimental support for C++ 11&#8221;, should be standard in the upcoming Ubuntu 13.10, but you can play around with it using a PPA:&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[127],"tags":[],"class_list":["post-3339","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/3339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3339"}],"version-history":[{"count":2,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/3339\/revisions"}],"predecessor-version":[{"id":6664,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/3339\/revisions\/6664"}],"wp:attachment":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}