I'm fairly far in a project using GTKmm atm, and I'm trying to add in some code a friend of mine have been working on. However I'm getting this error:
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
However I can't find anywhere that will actually let me add these compiler options.
Adding it to Build -> Configure Project only yields a:
Error: unrecognized option 'std=c++11'.
Anyone more familiar with this IDE who might be able to help?
Note that the commandline options start with a '-'. So the option is -std=c++11 (See man gcc).
Adding an option in Build -> Configure Project must be done like this
CXXFLAGS='-std=c++11'
You can also go to Project | Project options, then select your target in the top box. An options should appear 'More options'. Click on that, and you can enter -std=c++11 in the option field you want to use (probably Compiler flags).
It works here, but I have gcc version 4.8.x
Related
I want all my C programs to be compiled with the options -Wall -pedantic -ansi by default. Is there a way to have Eclipse add these flags to the compiler command by default for all projects?
Assign CFLAGS to include those values, and have Eclipse run a tool that uses that environment variable by default when compiling (such as make).
You may have to specify environment variables before running Eclipse (and then they get inherited when Eclipse runs make) but there might be a way to specify default environment in Eclipse.
(I don't use Eclipse, so I'll have to see about installing and testing this; or maybe this answer can jog someone's memory, if so, feel free to edit.)
As an aside, you might want -std=c99 instead of -ansi. The -ansi option simply means -std=c89 or -std=c++98, depending on whether you're compiling C or C++, and both of those standards are showing their age.
I installed Eclipse inside a VM running Windows to test this, and, even though CFLAGS is in the environment, Eclipse doesn't use it. Eclipse also pretends (by displaying text like "make all" and "make clean") that it's running make in a few situations/projects I tried, when it is not really using make (probably using some internal engine). This answer was on the wrong track for Eclipse.
Assuming you are using Eclipse's internal builder goto Preferences->C/C++ Build->Settings
Choose the warnings section for the compiler, there are tick boxes for -Wall and -pedantic
For -ansi set in Miscellaneous
As the OP notes this is just for each project not a global setting
Eclipse on Windows: For a project: Properties -> C/C++ Build -> Setting than "Tool Setting" tab. select "CGG C++ Compiler" than at the right side you will see Command : g++
modify it to Command: g++ CFLAGS for instance if you like to have C++11 support modify as Command: g++ --std=c++11
PS: This modification will valid for only current project and for only current configuration. If you want it for all configurations modify each configuration (Run, Debug) similarly.
EDIT: I see that the OP runs Windows from a prior comment, however the following information may benefit users of Eclipse on the Linux platform, if Eclipse honors the alias.
Are you running Eclipse in Linux? If so, try aliasing the gcc command; run this at a terminal:
alias gcc='gcc -Wall -pedantic -ansi'
This is a common method in Linux to specify default parameters for an application. However, Eclipse might execute the actual gcc application and ignore the alias; I have not tested it.
Yes, Run as -> Run configuration -> 1st Tab is "Main" , choose the second tab(the one next to it) , you have there arguments box, paste -Wall -pedantic -ansi and just apply then run. Every next time you run you'll have these arguments as default
I am trying to port over a windows c++ application to run on linux and I am using monodevelop. I have run into a compile error, and after some research I figured out that I need to specify the -std=c++0x flag for g++ to compile it correctly. When I run g++ with this flag on the command line it compiles fine. However, I cannot see a way to add this through monodevelop. Under options->Code Generation I see some text for "extra compiler options", but there is no way to add anything to this list. No buttons or text boxes are visible. I also opened up the .cproj file to see if I could just add it manually, but I am not seeing anything obvious where I would put this. Does anyone know how to add compiler options in monodevelop?
In monodevelop 4 and up, you can add custom compiler options such as -std=c++11 and so forth. To do this, you'll need the latest MonoDevelop installed, you can compile it manually from github or install it from the Ubuntu PPA http://ppa.launchpad.net/v-kukol/mono-testing/ubuntu .
After you have it installed, all you have to do is go to Project > 'Project Name' Options and go to Build > Code Generation and add the compiler options where it says Extra Compiler Options.
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
-> Miscellaneous: -std=c++11
-> Preprocessor: __GXX_EXPERIMENTAL_CXX0X__ (also set in C/C++ General -> Paths and Symbols)
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:
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.
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.
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
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)
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.
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.
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?
bump your gcc version to 4.7+. c++0x is supported since gcc4.3 while c++11 is supported since gcc4.7
Steps to configure through Netbeans IDE:
Right click on project and goto properties
Go to Build -> C++Compiler
In right hand side panel there are few options
go to Basic options -> C++ Standard
change its value from C++ 11 to C++ 98
I am running Eclipse Helios and I have g++-4.6 installed. Hope I am not wrong that g++4.6 implements C++ 11 features. I have created a C++ project which uses the nullptr and auto keywords. The build gives the following errors:-
../{filename}.cpp:13:13: error: ‘nullptr’ was not declared in this scope
../{filename}.cpp:14:2: warning: ‘auto’ will change meaning in C++0x; please remove it [-Wc++0x-compat]
Actually it was building fine until yesterday. I am getting these from nowhere today. Please help me solve this problem.
According to the GCC page for C++11:
To enable C++0x support, add the command-line parameter -std=c++0x to your g++ command line. Or, to enable GNU extensions in addition to C++0x extensions, add -std=gnu++0x to your g++ command line. GCC 4.7 and later support -std=c++11 and -std=gnu++11 as well.
Did you compile with -std=gnu++0x ?
Finally found out what to do. Added the -std=c++0x compiler argument under Project Properties -> C/C++ Build -> Settings -> GCC C++ Compiler -> Miscellaneous. It works now!
But how to add this flag by default for all C++ projects? Anybody?
You are using g++ 4.6 version you must invoke the flag -std=c++0x to compile
g++ -std=c++0x *.cpp -o output
Is that an actual compiler error or a Code Analysis error? Some times the code analysis can be a bit sketchy and report non-valid errors.
To turn off code analysis for the project, right click on your project in the Project Explorer, click on Properties, then go to the C/C++ General tab, then Code Analysis. Then click on "Use Project Settings" and disable the ones that you do not wish for.
Also, are you sure you are compiling with the C++11 compiler?
Go to Settings -> Compiler...
And add flag to "Have g++ follow the coming C++0x ISO C++ language standard [std=c++0x]
Trying with a different version of gcc worked for me - gcc 4.9 in my case.
I add the ",-std=c++0x" after "-c -fmessage-length=0",under Project Properties -> C/C++ Build -> Settings -> GCC C++ Compiler -> Miscellaneous. Dont't forget to add the comma "," as the seperator.