6

I am trying to use C++11. After sifting through the internet I found that all I have to do is right click on my project -> properties and under the "C++ standard" select c++ 11. When I run the program with C++ 11, I get this error "unrecognized command line option -std=c++11. One solution people have said is to add -g -std=c++0x in the "Additional Options" but then I get "unrecognized command line option -std=c++0x. I have downloaded gcc-4.7.1.tar.gz but I have no idea what to do with it.

Does anyone know how to get rid of this error or know how to make net beans compile with c++11?

ollo
  • 24,797
  • 14
  • 106
  • 155
Darren Hoehna
  • 269
  • 2
  • 8
  • 19
  • 2
    Which version of GCC are you using? Superficially, it appears to be one that does not, in fact, recognize the C++11 standard. If your version is older than 4.7, that is quite plausible. Check with `gcc --version`. – Jonathan Leffler Sep 11 '12 at 20:27
  • If you've downloaded the source for GCC 4.7.1, you now need to build it. This is a modestly complex operation. You'll need to make sure you have sufficiently recent versions of the GMP, MPFR and MPC libraries (or build them — in the correct order, which is GMP, MPFR, MPC, if I remember correctly). With those installed, you then create a directory `gcc-4.7.1-obj` where you have `gcc-4.7.1` (the extracted source), and `cd gcc-4.7.1-obj`. Then you run `../gcc-4.7.1/configure` (adding whatever options are necessary), followed by `make bootstrap`. It is a good idea to log the build. – Jonathan Leffler Sep 11 '12 at 20:32
  • There are a lot of options that you might need to provide to configure, and there are endless things that might go wrong, too. The outline steps above are no more than that — an outline (and an optimistic outline at that). Note that you need several gigabytes of spare space to build GCC (less than 4 spare GiB might cause trouble). – Jonathan Leffler Sep 11 '12 at 20:35
  • 3
    Depending on your operating system, there should be a way to install a newer gcc without having to build it from source. What OS are you using? – Keith Thompson Sep 11 '12 at 21:16
  • 1
    Your question seems to be either "How do I install gcc 4.7?" or "How do I select an installed compiler in Netbeans 7.2?" – Drew Dormann Sep 11 '12 at 22:48
  • @JonathanLeffler That seems really complex. I can try it though. Then how do I get an IDE that can run C++11? – Darren Hoehna Sep 12 '12 at 04:15
  • @KeithThompson I am running windows 7. I managed to get NEtbeans up and running using gcc by following http://netbeans.org/community/releases/60/cpp-setup-instructions.html – Darren Hoehna Sep 12 '12 at 04:19
  • It is moderately complex. If everything goes smoothly, it is a little time consuming, but the computer does it all; if anything goes wrong, you need experience to resolve it. I've built it on both Linux (RHEL 5— don't ask) and Mac OS X 10.7.4, and I've built previous versions of GCC on various machines over the years. As Keith suggested, maybe you should just find a pre-built GCC 4.7.1. It'll be available for your platform, almost certainly. – Jonathan Leffler Sep 12 '12 at 04:51
  • As for IDE, I'm not sure; I've yet to find an IDE that I understand, much less like. – Jonathan Leffler Sep 12 '12 at 04:52
  • I'll try then searching for a pre-built GCC 4.7.1 and see where my search takes me. – Darren Hoehna Sep 12 '12 at 15:15

2 Answers2

4

bump your gcc version to 4.7+. c++0x is supported since gcc4.3 while c++11 is supported since gcc4.7

-2

Steps to configure through Netbeans IDE:

  1. Right click on project and goto properties
  2. Go to Build -> C++Compiler
  3. In right hand side panel there are few options go to Basic options -> C++ Standard change its value from C++ 11 to C++ 98
Alessandro Minoccheri
  • 35,521
  • 22
  • 122
  • 171
Sanjay
  • 13
  • 3