Guide to Configure NetBeans IDE for C++

G

Recently in a project, I had to test some APIs using C++. To setup the testing environment, I did some R&D and decided to use NetBeans IDE for C++. Decision was based on many factors but mainly it was because of some project requirements. As we all know NetBeans is primarily a Java IDE, but it also has a very good support for C++ as well. In NetBeans, we can work with C/C++ applications by using dynamic or static libraries.  We can also start projects from existing code, and there are many advanced features that make it a very good option to work on c++. In this blog I will walk you through the steps that you will need to perform to completely setup the NetBeans IDE and make it ready to work on C++ projects.

1- Download the suitable version NetBeans IDE from NetBeans Download Page. You can either choose the Full version containing all components or the CPP version with components required for C/C++.

2- Install the NetBeans. It is quite simple and straight forward process to do it. If you face any difficulty let me know in comments or consult the NetBeans on site guide.

3- After the NetBeans is successfully installed, open it and check if c++ is already integrated or not.

You can check it by going to menu >>> File > New Project > and see if c++ directory is displaying or not. If it is displaying, then it means that C++ is integrated and you can move to step-5. Otherwise follow the process in step-4

4- If directory is not displaying, then it means that we need to install plugin for c++

We can do it by going to menu >>> Tools > Plugins > Available Plugins > C++

Select it and Install (Select download server of your choice and accept to agreement)

After the Plugin has been installed, restart the IDE.

5- On this stage, you can try to create a new c++ project to verify if everything is ready. While doing so you might get the following error message..

Build host is not connected. Compiler is not set for NetBeans c++.

If you observe this message, then it means that c++ compilers and tools are missing from your system and you need to install them to work with c++ projects. For installing compilers we have options to either install Cygwin  or MinGW. I found that MinGW is easier to proceed so I decided to go with it. Following are the steps to install and configure MinGW…

a) Download the MinGW exe. I used following Softpedia link to download MinGw .

Once downloaded, Run the MinGW installer and choose to install the required components. I selected all of them (except MinGW make, as we will be using make from MSYS, as instructed in NetBeans official guide. We will download and configure it in later steps.). This installation process can take some time depending on net connection as some components will be downloaded during installation. After the installation has been completed add the MinGW directory to Windows Environment variables “path”.

It can be done by following these steps…

Windows> Start > Settings> Control panel> Settings > Advanced > Environment Variables..

Edit already present "path" in the list, and enter compiler directory path after a semi column ; like this..

;C:\MinGW\bin

Click OK.

If you still face any issues in setting up enviornment variables then visit my detailed blog on ‘How to setup windows environment variables’.

b) Next you need to  download and install MSYS exe and run it.

To avoid any issues and conflicts, it is preferable to choose MinGW directory as the destination installation directory for MSYS.

c) After MSYS installation, next we need to install gdb Debugger . Visit this download gdb Debugger link to download it.

After all these installations are finished, restart NetBeans IDE.

Now to very ending steps:

Go to TOOLS > OPTIONS > C++ > BUILD HOST>>

Press ADD button to add build host..
Browse to C:\MinGW\bin in Base Directory.
Select MinGW in Tool Collection family and Tool collection Name.. (or they will automatically get selected)

mingw-netbeans-add (1)

Press OK.

After going through all these steps, you are ready to work with NetBeans IDE for C++. If you have any confusion in above steps or face any other issue then feel free to ask in comments.

Arif Masood

Software Quality Professional. Perfectionist. Love to explore new tools, technologlies & processes. Worked on several web & mobile projects in last 7+ years. Mostly in areas of Functional, API, Automation & Performance testing. Ocassional blogger - trying to be more regular one :)

Posts

Tags