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
Related
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
I’m trying to include openmp to my Xcode C++ project. I have changed my compiler in Xcode to LLVM GCC 4.2, added ”-fopenmp” as a CFlag and enabled OpenMP support in xcode as well. But it still says ”‘omp.h’ file not found” and i am unable to build the project. Does anyone know what could be wrong and how to fix this?
I have had the same problem. Try going to the project navigator using the panel at the left side. Select your project (the one with the blue icon), and a different main window appears. Here, click the relevant file under "Targets" and choose the "Build settings" and "All". Here, search for OpenMP. In my system, it shows up under "LLVM GCC 4.2 - Language". Set "Enable OpenMP Support" to Yes. This should make it work. Make sure to not manually #include "omp.h".
The weird thing is that I don't know how to do this "manually" (i.e. circumventing the built-in Xcode I approach described above).
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.
How do I use a c++ compiler (g++ or clang++) to compile a simple c++ project in xCode 4?
You can assume I am in the project, in the Build Settings.
I have in Build Options -> Compiler for C/C++/Objective-C -> Apple LLVM compiler 3.0 and LLVM GCC 4.2 as options.
Is either one appropriate or do I have to install another one?
How do I do that?
For running a simple code with Xcode after running Xcode choose “Create a new XCode project”. (You can also go to “File|New|New Project...” or press Shift-⌘-N). This will bring up a screen in that screen select "Application"then select "Command Line Tool" and then click next .Now enter a name for your project and select type c++ and click next in upcoming screen select a directory for you project and click "create" now you can write codes in main.cpp file in the left panel for running your code just click on "Run" button .
Update:
In Build options click "Build settings" and then click "All" from "C++ language Dialect"and "C++ standard library"tab you can choose the compiler and c++ standard that you want included c++11.
I am trying to load my xcode project into textmate so that I can compile and run using the xcode bundle in textmate.
When I compile my project in XCode it works fine, but when I load it up into textmate and I try to compile and run using the XCode bundle I get C99 errors due to my for loop syntax.
Has anyone run into this situation before? My XCode project is of the "Command Line Tool" template and I selected the "C++ stdc++" type for the project.
EDIT: The error I am specifically getting is:
Error: 'for' loop initial declaration used outside c99 mode
on the following line:
for(int i = 0; i < value; i++){
Again, I am only getting that error when I tell the TextMate XCode bundle to build and run, but it works just fine if I load up the project in XCode. I am also referencing the OpenCL framework as well in the XCode project, but I'm not sure how that would cause something like this to occur.
Thanks!
You need to set your C dialect to C99, which is an update to the language, standardized in 1999, with slight differences from "ANSI C."
In Xcode:
Select either your project or target (whichever you deem appropriate for this setting change.)
Open the File menu and select Get Info.
Select the Build tab in the window that appears.
Find the "C Language Dialect" option and set it to C99.
Recompile.
An update for Xcode 4:
On the left panel, click on the project icon/Name
Look for 'C Language Dialect' under 'LLVM GCC 4.2 - Language'
Set it up C99 [-std=c99]