C++: Compiling a simple C++ program on Netbeans

This entry is part 40 of 61 in the series C++

Now that we have configured the C++ compiler in Netbeans, we can test it out by running a simple C++ program to see if we have the Compiler properly installed.

1. From the menu in Netbeans, go to File -> New Project.



3.  As in the screenshot above, in the Categories, select C/C++

4.  In the Projects column, select C/C++ Application.  Click on Ok.

5.  In the next windows, you can leave it as it is and click on Finish.


6.  Under the source file, you should see a main.cpp



8. Click open it and you can see a template being created for us.

9.  We will add the iostream library and a cout statement to display a string as shown below.

 * File:   main.cpp
 * Author: daryl
 * Created on January 24, 2015, 11:07 PM

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    cout << "Hello, World";
    return 0;

10. Now click on the green arrow button or press F6 to run the program.




C++: Configuring Cygwin compiler to work with Netbeans

This entry is part 39 of 61 in the series C++

After you have downloaded Cygwin and installed with the C++ compiler and make utility, it is easy to set it as the C++ compiler for Netbeans.

  1. Launch Netbeans
  2. From the menu, go to Tools->Options->C/C++
  3. In the tool collection, click on Add
  4. cygwin8
  5. We will have a Windows similar to the above
  6. In the base directory, set it as C:\Cygwin\bin
  7. cygwin9
  8. From the drop down menu in Tool Collection Familly, we select the latest version 4.0.
  9. Our last steps are to add the g++.exe as our compiler, set the make utility and gdb as our debugger as show in the screenshot below.
  10. cygwin10
  11. Once these are done, our compiler should be properly set.
  12. We will perform a simple test in the next post.

Learn C: Setting up the environment

This entry is part 1 of 7 in the series Learn C

Let’s start with the C language first.

The first thing is to get your computer set up so that you have a compiler to compile C.

This post will use the GNU C and if you prefer, you can set up the Visual Studio shown in a later post.

GNU (Geez, Not Unix) C compiler can be downloaded from http://mingw.com.  Visit the website and download the MinGW installation manager.


From the installation manager download gcc-core, gcc-g++, binutils, and the MinGW runtime. Next set the path of the windows to the bin directory of MinGW.

Now that you have the environment set up, you can write your first C program.