How to compile a project with C++11 under Xcode 8? - c++

This question was asked many times and I failed to replicate all of the solutions I could find. I am unable to find this setting under File->Project Settings (as some suggested). Please be very specific. If you know an answer for Xcode 7, chances are it will work for me too.

It's the same for 7 and 8. From the Project Navigator, select the project. In the main panel, at the top left, select the target. Now the main panel should have General, Resource Tags, Build Settings, Build Phases, & Build Rules along the top. Select Build Settings, select All. Scroll down to "Apple LLVM 8.0 Language C++" and expand it. Change "C++ Language Dialect" to "C++11 [-std=c++11]".

Build Settings -> Linking-> other linker flags -> add to "-lc++"

Related

Netbeans 9 C++ Support

I wonder if there is a support for C++ in Netbeans 9. This link shows C++ on screenshot (when creating new project). However, after installing, I don't have one.
I wonder if there is a support for C++ in NetBeans 9.
The answer to that is definitely no, and definitely yes...
No, in the sense that the use of C++ on NetBeans 9 is not currently supported by Apache, and it is done at your own risk. NetBeans is currently being handed over from Oracle to Apache, and they haven't got to the C/C++ part yet. See What's Happened to My Favorite NetBeans Plugins? for more information.
Yes, in the sense that it is technically feasible to do it; the NetBeans 9 IDE allows you to use C/C++.
This is what you need to do:
Step 1 of 2: Make C/C++ available as a plugin.
Tools > Plugins > Settings tab > click the Add button.
On the Update Center Customizer screen:
Enter some value in the Name field (e.g. "My plugins"),
Enter http://updates.netbeans.org/netbeans/updates/8.2/uc/final/distribution/catalog.xml.gz in the URL field
Click the OK button.
This should create a new entry in the Configuration of Update Centers list in the Settings tab.
Checking that new entry should instantly add plugins to the Available Plugins tab.
Click the Available Plugins tab, then click the Category column to sort the entries by category.
The Name of the entry at the top of the list should be C/C++. If so, you have successfully made the plugin available:
Step 2 of 2: Install the C/C++ plugin.
Check the C/C++ entry shown in the screen shot above, and then click the Install button.
Follow the wizard's instructions. The plugin will be downloaded and installed, and you will be required to restart NetBeans.
To confirm that C/C++ has been installed, click Tools > Plugins > **Installed tab. You should see an entry for the C/C++ plugin you just installed.
Also, verify that you can now create a C/C++ project through the Project wizard:
Notes:
The finer details on configuring C/C++ on NetBeans 9 (Tools > Options > C/C++) are unchanged from NetBeans 8.x. Refer to Configuring NetBeans IDE 8.0 for C/C++/Fortran for that.
Much of this answer has been copied from an answer I gave on problems with Tomcat on NetBeans 9, but the details are sufficiently different to merit a separate answer.
Netbeans 10 and 11 - adding C / C++ also works in the same fashion.
In Netbeans go to Tools->Plugins->Settings
Entry NetBeans 8.2 Plugin Portal is already present.
Click the checkbox next to this entry.
Switch to Available Plugins tab, click Check for Newest.
C / C++ is now on the list.
Computer that this is done is on Windows 10 x64.
You have to install C++ plugin (Tools -> Plugins)

Eclipse CDT missing features

We have a C++ project we want to enhance using Eclipse on Linux (CentOS 7). We have one Linux VM with Eclipse and CDT (a C++ plug-in) installed. Using CMake, we generated make files for the project and brought it up in Eclipse (File → Import → General → Existing Projects into Workspace). From there we need to do some fixes to make it compile C++ 11 code. We do this via the "Properties → C/C++ General → Preprocessor Include Paths, Macros etc." page. It all builds and works fine.
We created new Linux VMs with the same version of Linux. We installed Eclipse (Oxygen) and installed the CDT plug-in. We followed all the same steps as above, except in these new VMs, there is no "C/C++ General → Preprocessor Include Paths, Macros etc." option in the Properties dialog. We can get the code to compile as C++ 11, but the IDE itself doesn't recognize C++ 11 and marks most of the code as errors. If we had the "Preprocessor Include Paths, Macros etc." page, we could makes the necessary changes, but for the life of us, we can't figure out why it doesn't show up in the new VMs. Both Eclipse installs have the same plug-ins (one, namely, CDT).
Is there something we're missing? Is there another way to access the options that the missing page allows?
UPDATE
Perhaps some visual will help. Here is what the Properties page looks like when opened on the original Linux VM:
Here is what the Properties page looks like when opened in the new VMs:
As you can see, in the second image, there is no "Preprocessor Include Paths, Macros, etc." option underneath "C/C++ General". That is the problem. Without that page, we can't do several things to the project we need to to get it to operate correctly.
I can't really be proud of our solution to this problem. The version of Eclipse that works is Oxygen.1a Release (4.7.1a). The "latest and greatest" release of Eclipse (at the time) was Oxygen.2 Release (4.7.2). We downloaded and installed 4.7.1a and it worked. There must be a defect in 4.7.2 that prevents it from correctly recognizing C++ 11 code.
Oxygen.1a 4.7.1a imports the project perfectly and shows up all the options we need to make changes and get the application to compile and run correctly.

C++ Lambda error on Mac (gcc out of date?) [duplicate]

This question was asked many times and I failed to replicate all of the solutions I could find. I am unable to find this setting under File->Project Settings (as some suggested). Please be very specific. If you know an answer for Xcode 7, chances are it will work for me too.
It's the same for 7 and 8. From the Project Navigator, select the project. In the main panel, at the top left, select the target. Now the main panel should have General, Resource Tags, Build Settings, Build Phases, & Build Rules along the top. Select Build Settings, select All. Scroll down to "Apple LLVM 8.0 Language C++" and expand it. Change "C++ Language Dialect" to "C++11 [-std=c++11]".
Build Settings -> Linking-> other linker flags -> add to "-lc++"

XCode 5 vs XCode 4 - where are the options

My old Mac had 10.6 and XCode 4.2 (which was the latest for that system). There I was able to select "Other C Flags" and "Other Link Flags" and set them appropriately.
Now I got a Mac which has 10.8. I install XCode 5.1.1 and I couldn't find those settings anymore.
Are they being split up? Renamed? If that's the case how do I set them up?
I know its not actually a programming question, but its tightly related and also I asked to post XCode related stuff here on SO from "Ask Different".
Thank you in advance and hopefully this question is OK to ask here. If not please point me to the proper place on any SO site and I will gladly move it.
I think this is indeed a programming question, since it has to do with Xcode.
If you open your project in Xcode, select the target (which is the app you ultimately build) and then click on "Build Settings".
There should be a search field into which you can type in the search term "Other".
Here's a screenshot of what I see when I do this in Xcode 7:
I've circled "Other Linker Flags" and "Other C Flags" for you. You should see the same results in Xcode 5 & 6.

Cross compiler prefix and path in eclipse

I'm trying to create a C++ project on eclipse. I have installed eclipse-cdt for that.
While creating a project, a pop up window asks for cross compiler prefix and cross compiler path. Could someone please explain what are those and what do I need to add in those fields? Are those fields absolutely necessary to fill?
If you are using a Mac, you can select MacOS GCC instead of Cross GCC. If you are on Windows, you will have to install a C++ compiler. I recommend you install Cygwin, try following the directions here.
https://www3.ntu.edu.sg/home/ehchua/programming/howto/eclipsecpp_howto.html
Once you've installed the C++ compiler, restart Eclipse and try to create the project again. Hope this helps.
In Cross compiler Prefix you need to write 'arm-none-eabi-' and in Cross compiler path you have to select the path for GCC bin folder. You need to install Cygwin GCC for this.
I have found few steps in below link.
https://www3.ntu.edu.sg/home/ehchua/programming/howto/Cygwin_HowTo.html#cygwin
Just in case anybody else is like me and needs more explicit directions as #yeremy is correct in that you have to select MacOSX GCC. It's just that at the point where the OP is, he overshot where he could have made the selection and needs to back up a few windows (about 3) to choose the MacOSX GCC as the Toolchain of choice. Attaching a link below which goes through the steps and which also shows image of window where you can make the selection (figure 11).
Getting Started with C++ for Eclipse - CodeGuru
When Eclipse doesn't detect a toolchain (to be installed separately) it only offers the option "Cross GCC". Don't choose that.
Sites like this tell you that a properly installed toolchain (Cygwin / MinGW) is automatically discovered using the PATH environment variable. This is not the case on my machine.
There's no way to configure a toolchain in Eclipse manually (as of writing) but you can fool Eclipse into finding one without changing your global PATH:
Go to Preferences/C/C++/Build/Environment,
Add a variable PATH and point it to your toolchain path(s), e.g. d:\Mingw\bin;d:\Mingw\msys\1.0\bin. Separate paths with a semicolon.
For newbies just starting out C++ projects in Eclipse:
1 - Click File --> New--> C/C++ Project
2 - In the "Templates for New C/C++ Project" window, Select C++ Managed Build --> Click Next
3 - Provide a project name --> Select "Empty Project" in Project Type section (which is under Executable) and Select "MinGW GCC" in the Toolchains section
4 - Click Finish
Note: Selecting "MinGW GCC" will eliminate the headache of inputting the Cross GCC related prefix and path. Happy C++ learning.
enter image description here