How do you enable C++17 in Netbeans? - c++

In Tools > Options > C/C++ > Other, there is no option for C++17 as the default standard.
How do you compile code that requires C++17?

Updated 3/28/21 for NetBeans 12, as documented at the end of this answer.
The C++17 standard was published over a year after NetBeans 8.2 was released, so C++17 is not available as an option in the standard release of 8.2.
However, NetBeans Bug Report Bug 271136 - Support C++17 standard addressed this deficiency, and if you download and install any of the most recent nightly builds of NetBeans 8.2 from 2018 the issue is resolved; C++17 is available as an option when creating a C++ project:
If you then select {project} > Properties > Build > C++ Compiler you can verify that the C++17 standard is being used:
Notes:
When you create subsequent C++ projects, the project wizard will continue to use the C++17 standard by default, so it becomes "the default standard" unless/until you select an alternative.
Using a nightly build of NetBeans 8.2 instead of the standard release is also preferable because it contains many unrelated bug fixes.
An even better alternative (if it is possible for you) is to download and install the latest release of NetBeans, Apache NetBeans 11.2 which also provides C++17 as an option.
If you install a nightly build of NetBeans 8.2, or NetBeans 11.2, your existing installation of NetBeans 8.x will not be touched, so you can safely revert if necessary.
Updated 1/21/20 and 1/22/20:
These are the steps needed to make C++17 available on NetBeans 11.2:
Opening the project wizard using File > New Project... shows that C/C++ projects cannot be created by default.
Select Tools > Plugins > Settings then click the Add button.
In the Update Customizer Center screen, set Name to NBDevDarkThemes and URL to http://bits.netbeans.org/dev/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/nbms/updates.xml.gz and click OK.
Ensure that only the entry for NbDevDarkBeans on the Settings tab is checked.
Install the C/C++ plugin by clicking the Available Plugins tab, then checking the entry for C/C++. The version for that plugin should be 1.31.5.1. Click the Install button.
After the plugin has been installed, click the Installed Plugins tab, check the Show Details checkbox and scroll down to verify that the C/C++ plugin is installed and Active:
Go to Tools > Options > C/C++ >, click the Build Tools tab and configure your external C/C++ environment as required. For example:
Now go to File > New Project... and you should be able to select C/C++ > C/C++ Application.
Click Next >. On the Project Name and Location screen you should now be able to select C++17 for the standard:
Updated 3/28/21 for NetBeans releases 12.x:
Bad news: NetBeans no longer officially supports C++! See the definitive response from Geertjan Welenga, leader of the NetBeans Team, dated 3/25/21 in response to the recent bug report NETBEANS-5501 C++17 no longer available:
*At the moment, NetBeans doesn't support C/C++, the plugins you were/are using from 8.2 are not really officially supported, though work on this is ongoing here, with an end goal to having it officially part of NetBeans, though that will take a while:
https://lists.apache.org/thread.html/r4ac84633554ce80d99b0710e7a803ce1dc322680c914b18058876b51%40%3Cdev.netbeans.apache.org%3E
You're welcome to join in with the discussions on dev above.*
That said, there is an unofficial workaround, as detailed in bug report NETBEANS-4452 The Plugin Installer found problem timeout of loading C/C++ Remote Development API... while install the following plugins: C++. That is:
Download JDK 8 (if necessary).
Temporarily set the JDK NetBeans 12 uses to JDK 8 by editing netbeans.conf, then restart NetBeans.
Install the relevant C/C++ plugins.
Reset the JDK NetBeans 12 uses to the one you were using originally - presumably to JDK 14 for most users - by editing netbeans.conf, then restarting NetBeans.
C++ 17 should then be available on NetBeans 12, on the clear understanding that it is not officially supported.

The accepted answer completely valid, but the old plugins repository was shut down, and oracle now redirects all links to their infrastructure to the apache site. It means that we can now download plugins only provided by apache.
To add support for C++ 17 to NetBeans 11 (was tested only on 11.0, but some reported that it worked on 12.3, see the comments), you need to do the following
Manually add plugins of the CND module that provides such support. The version of the plugins should be more than 1.31.5.1
Ensure that NetBeans uses JDK8 because old plugins required a upack200 module. It's unavailable, for example, in JDK14.
Steps to install it manually
I downloaded all plugins (NBM files) you need for C++17 support. You can download it here. Beare in mind that the pack was tested only with 11.00 NetBeans. Please, use 11.0 NetBeans.
Then you need to unpack the archive to a folder
Start NetBeans, go-to Tools -> Plugins -> Downloaded.
Click Add Plugins and select all plugins in the archive. Check that you have 64 plugins for installation. Why you need so many plugins? Because the C++ plugin depends on other plugins. So you need to provide the newer versions.
Click install. There will be a warning that additional plugins will be installed:
After installation, go to the Installed tab, check Show details option and find the C/C++ Plugin. Verify that the version is 1.31.5.1:
Automatic installation
The truth is the nightly builds repository was not completely shutdown. You need to know the exact IP address for accessing it.
So you could use all the steps from the accepted answer but instead of the link
http://bits.netbeans.org/dev/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/nbms/updates.xml.gz
you should use:
http://137.254.56.27/dev/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/nbms/updates.xml.gz
But oracle can restrict access to it at any moment. And also, ensure that your NetBeans runs on JDK8 (upack200 issue).
NetBeans 8.2 Dev Build with C++17 support
If you are looking for old 8.2 release with C++17 support here the last dev build (20180420) from oracle. It runs only on JDK 1.8

Related

View the source code C++ in Eclipse - Ubuntu environtment

I had loaded the project to Eclipse but when I open the .cpp file, it like to open a text file.
Anyone know how to display the code-view in eclipse?
Please support.
Thank you so much.
I cannot find C/C++ in Window -> Preferences
Then you have no CDT installed – I suppose you got the version direct from the initial download page, but that's actually the java package – there's a link 'download packages' below, where you would have found the C++ package. Not too obvious, admitted.
Never mind, you don't need to re-install: Help -> About will reveil you your installed version's name ('Kepler', 'Luna', ...); via Help -> Install new packages you can add CDT plugin to your installation. Select under work with your release version of eclipse repository, e. g. http://download.eclipse.org/releases/photon.
Minimally, you need: C/C++ Development Tools, other plugins might be useful, too, like standalone debugger, call graph visualisation, unit testing support, auto tools support (configure, make; especially under linux), possibly LLVM support (if you want to use clang compiler), ...
My issue had been fixed.
Just do below steps in ubuntu:
Go to
https://www.eclipse.org/cdt/downloads.php and download newest CDT(C/C++ Develop Tool) version.
Copy the download file
eclipse-cpp-2018-12-R-linux-gtk-x86_64.tar.gz
to your folder in Ubuntu.
Extract
eclipse-cpp-2018-12-R-linux-gtk-x86_64.tar.gz
Run execute eclipse file -> Done.

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.

How do I set up C/C++ on Eclipse in Windows?

I just did the default Java (8) installation of Eclipse on my Windows (8, yikes) laptop, and it seems to work just fine. However, I'm not as good at Java as I am with C and C++, and for some work it's more expeditious to use C/C++ than Java.
Unfortunately, the Eclipse installer for Windows doesn't make it very easy to set up Eclipse for C/C++. It looks like I'd be fine with Linux or BSD, but then I'd have to scrounge up another laptop (because I need the mobility) and install Linux or BSD on it. Yes, I need to leave Windows on this machine, so Windows hate isn't going to help me.
My lazy web search turned up this article: "Install Eclipse for C++ Development on Windows 7 64-bit". Is there a better installation guide than that, or does anyone care to describe the process in more detail?
Even though you have CDT features installed, you need to install a GCC compiler for windows such as MinGW or Cygwin. Once you install them, add the 'bin' folder in the installed path to the environment variables and then restart eclipse. You should now see MinGW compiler when you select "Create new C Project". After this step, proceed with your C programs and this should resolve your problems.
You will have to install a GCC compiler in your PC and then link it to the project each time you create a project. This can be done while you create a new project, or even after you have done so. You can download MinGW compiler through the following link
https://sourceforge.net/projects/mingw/files/latest/download?source=files
Once you have downloaded the compiler and installed it, it can be linked through the following steps:
i. While creating a new project, choose MinGW GCC compiler in the tool chains.
ii. Once you have finished creating a project, go to Project->Properties.
iii. Look for Run/Debug Settings in the left panel.
iv. Click on the New tab and select C/C++ Application.
v. Look for Environment option.
vi. Click on the New tab.
vii. Type "PATH" in the Name bar and fill the Value bar with the path of the compiler. For me, its C:\MinGW\bin.
vii. Click on OK and you are done!
The instructions you link to have you install Eclipse IDE for C/C++ developers which will work fine to get a C/C++ development environment up.
If you would instead like to use your EXISTING installation of Eclipse and add C++ Development Tooling (CDT) you can launch Eclipse and then use Install New Software to install the C/C++ Development Tools

How to create x64 version of native console project?

I have a VS2008 solution with several libraries and 4 console apps. All build and run correctly in 32 bit mode. The libraries all build and run in x64 mode in another solution with a C# app and a C++/CLI interface layer.
Now I need to build an x64 flavor of the 4 console apps (functional and unit tests for the libraries).
On the Configuration Manager dialog, the Platform dropdown for these 4 projects offers only Win32 as an option. (x64 is also there for the libraries). The Edit and New options are there but do not seem to offer a way to create an x64 choice.
Presumably VS2008 is disallowing x64 for some reason. Is there some other attribute or option I need to set first?
EDIT: Trying to create a new platform in Configuration Manager fails because there already is an x64 platform. It is available to all the library projects.
If you don't get "x64" in the New Platform combo then the x64 C/C++ compilers are not installed. They are not by default (remarkably) unless you started the VS2008 install with the Custom option and turned the option on. Rerun setup.exe to add them, don't forget to rerun the SP1 setup as well. You can double-check by verifying if the vc\bin\amd64 folder is present in the VS install folder, that's the home of the 64-bit build tools.
Another trap exists when the x64 platform already exists in the solution file, brought in by the managed projects. Be sure to untick the "Create new solution platform" checkbox in the dialog.
It's well supported. You just need to add the platform before it appears in drop-down lists:
Build/Configuration Manager
Active Solution Platform
<New...>
x64
If you are using VS 2008 Express, it will not include x64 support.
EDIT: If the configuration already exists on the solution, but not on the project, use this sequence:
Build/Configuration Manager
Go to the line with the project, column Platform
Drop-Down list, <New...>
x64