iammilind
iammilind

Reputation: 69988

Eclipse Juno CDT: Incompatibility with C++11 and debugging issues

Facing variety of issues with the latest Eclipse Juno in Ubuntu 12.04, after switching from Indigo.
I have set below flags in:
Project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> Cross G++ compiler

Presently, I am compiling the code which was compiling fine with C++03 in Indigo. After changing to C++11, I did get some errors which were probably due to g++ extension, and I have fixed them.

Now here are the problems which I want to fix:

  1. If I switch back to normal C++ compilation, then I receive single error: This file requires compiler and library support for the \ ISO C++ 2011 standard. This support is currently experimental, and must be \ enabled with the -std=c++11 or -std=gnu++11 compiler options. from the file c++0x_warning.h. The error doesn't go away even with clean build or restarting the eclipse.
  2. Debugging doesn't work as expected. The execution does stop at given break points, but when I hover my mouse on the variables, it doesn't show any values. In Indigo it used to show it. Did lot of trials and errors in various settings of Eclipse, but no luck. Also checked, Window -> Preferences -> C/C++ -> Hovers, but unable to change anything there.
  3. Including <unrodered_map> works fine, but if std::unordered_map<> is used then it starts giving error. For now, I am least concerned with this issue among others.

If anyone can suggest a link or method to do the effective debugging with Eclipse (Juno), then it will be of great help for future visitors as well.

Note: I have referred several threads in SO, but none of them were helpful:
Eclipse CDT C++11/C++0x support
Cannot set Eclipse Juno C++ with std=c++11
Eclipse CDT Juno - Toolchain issue

Upvotes: 1

Views: 2219

Answers (1)

Nafiul Islam
Nafiul Islam

Reputation: 82470

First of all, I started off with a fresh installation of the whole thing, and as something for future reference, I want to show how to install and use GCC with Eclipse from scratch.

Firstly go to the Ubuntu Software Center, and download the latest versions of GCC, which is GCC 4.8. Now, you might encounter problems doing this, so I suggest that you type in gcc-4.8 when trying to find the software. Same thing with g++, you type in g++4.8 to get what you want. Make sure you have the right versions. Due to the open source nature of Linux, there tend to be lots of problems involving versions.

-> : press enter

Now, open up your terminal, and enter the following:

  • sudo su - -> this will give you special root privileges.
  • Now it will ask for your password, enter that ->
  • !Warning, make no mistakes in this part, since root can do a lot of damage!
  • Now change your directory, enter cd /usr/bin ->
  • Type ls -l gcc* g++* cpp* ->
  • This will show you the symbolic links available to those data types
  • Type ln -s g++-4.8 g++->
  • Type rm cpp gcc ->
  • ln -s gcc-4.8 gcc ->
  • ln -s cpp-4.8 cpp ->
  • Now CTRL + D, twice, and that will move you out of the terminal.

Now, open up eclipse. Go to Preferences>New CDT Wizard(or something like that) enter image description here Make sure that Linux GCC is selected. Make press the Make Toochains preferred. Now, when you open up a project, make sure you go to the project properties, and you do the following:

  • C/C++ Build > Settings > Misc. > Under other flages add this -std=c++11. enter image description here

  • Same thing with GCC C compiler, but this time, you add -std=gnu11

That should set everything up. Don't use Cross GCC, it has always given me problems.

Upvotes: 1

Related Questions