How to Run C/C++ Program in Netbeans on Windows

This tutorial will take you through the process of running a C/C++ program with the Netbeans IDE (Integrated Development Environment) using screenshots as tools for understanding and clarity. This article is written for use with Windows,...

Part 1 of 5:

Downloading the Components

  1. Picture 1 of How to Run C/C++ Program in Netbeans on Windows
    Open each of the following links in separate tabs.
    1. Netbeans
    2. Compiler and Debugger
  2. Picture 2 of How to Run C/C++ Program in Netbeans on Windows
    Download Netbeans
    1. Select the Graphic on the right
      Picture 3 of How to Run C/C++ Program in Netbeans on Windows
    2. Accept the user agreement, and then select the correct software from the list. Choose either the file ending in i586 for a 32-bit system or the file ending in x64 for a 64-bit system. Save to your Desktop.
      Picture 4 of How to Run C/C++ Program in Netbeans on Windows
  3. Download Compiler and Debugger
    1. Select the Correct File for your System and Save it to your desktop
      Picture 5 of How to Run C/C++ Program in Netbeans on Windows
Part 2 of 5:

Installing Cygwin Compiler and Debugger

  1. Picture 6 of How to Run C/C++ Program in Netbeans on Windows
    Create a Folder on the Desktop and name it Cygwin
  2. Open the Cygwin Installer
    1. Click the "Next" button on the window that comes up
  3. Picture 7 of How to Run C/C++ Program in Netbeans on Windows
    Click Install from Internet, Click Next, then Click Next on the Second window
    1. Make sure on the Third Window that the path is setup to the desktop folder
      Picture 8 of How to Run C/C++ Program in Netbeans on Windows
  4. Select a Download Site and click Next
    1. Really does not matter what site is chosen, however download speed may be affected
  5. Install Compiler and Debugger
    1. On the Window that pops-up select the '+' next to Devel
      Picture 9 of How to Run C/C++ Program in Netbeans on Windows
    2. Find the files called gcc-core, gcc-g++, gdb: GNU Debugger, and 'make', and click the 'Skip' button to the left ONCE.
      Picture 10 of How to Run C/C++ Program in Netbeans on Windows
      Picture 11 of How to Run C/C++ Program in Netbeans on Windows
    3. Click Next
    4. It will install the parts and then ask if you want shortcuts, you do not need these
  6. Create the Cygwin Path
    1. Open your control panel and select "System and Security", then select "System"
    2. Click Advanced System Settings
    3. Near the bottom of the new window there will be a button called "Environmental Variables", select it
      Picture 12 of How to Run C/C++ Program in Netbeans on Windows
    4. In the window that pops up scroll down to Path, select it and click Edit
    5. At the end of the highlighted text (DON'T DELETE IT) add, with no spaces at all, ";cygwin-directorybin"
      Picture 13 of How to Run C/C++ Program in Netbeans on Windows
Part 3 of 5:

Installing Netbeans

  1. Picture 14 of How to Run C/C++ Program in Netbeans on Windows
    Open the Netbeans Installer
    1. Allow program to run, if asked for permission, and wait for installer to configure
  2. Picture 15 of How to Run C/C++ Program in Netbeans on Windows
    When the installer Opens
    1. Click Next
    2. Agree to the user agreement and select Next
    3. Allow the installer to save and install the files on the next two windows to the default locations
    4. Click Install
    5. You can choose whether to send usage data or not
Part 4 of 5:

Running the Program

  1. Picture 16 of How to Run C/C++ Program in Netbeans on Windows
    Open Netbeans
  2. Picture 17 of How to Run C/C++ Program in Netbeans on Windows
    Click the "My Netbeans" tab
  3. Picture 18 of How to Run C/C++ Program in Netbeans on Windows
    Click Install Plugins
    1. In the search bar type C/C++
    2. Select the result that has the same name and click it
    3. Click Install
  4. Picture 19 of How to Run C/C++ Program in Netbeans on Windows
    Click Next in the new window
    1. Accept the User Agreement and Click Install
  5. Picture 20 of How to Run C/C++ Program in Netbeans on Windows
    Exit the Plugin Window
  6. Picture 21 of How to Run C/C++ Program in Netbeans on Windows
    Click File in the top left corner
  7. Picture 22 of How to Run C/C++ Program in Netbeans on Windows
    Click New Project
  8. Picture 23 of How to Run C/C++ Program in Netbeans on Windows
    Select C/C++ in the new window
    1. Select C++ Application on the right side
      Picture 24 of How to Run C/C++ Program in Netbeans on Windows
    2. Select Next
  9. Picture 25 of How to Run C/C++ Program in Netbeans on Windows
    Name the Project whatever you'd like, and make sure that the tool collection field has Cygwin in it
    1. Click Finish
  10. Picture 26 of How to Run C/C++ Program in Netbeans on Windows
    Double-Click the Project on the left-side of the screen
    1. Click the '+' next to Source Files
  11. Picture 27 of How to Run C/C++ Program in Netbeans on Windows
    Double-Click main.cpp
  12. Picture 28 of How to Run C/C++ Program in Netbeans on Windows
    Insert the phrase (No quotes) "#include " underneath the other include phrase
  13. Picture 29 of How to Run C/C++ Program in Netbeans on Windows
    Insert any code inside the curly brackets of the main function
    1. For example insert (no quotes) "cout << "Hello World" << endl;"
  14. Picture 30 of How to Run C/C++ Program in Netbeans on Windows
    Click the hammer icon at the top to build the solution
    1. If done correctly at the bottom in green, a message will appear that reads "Build Successful"
      Picture 31 of How to Run C/C++ Program in Netbeans on Windows
  15. Picture 32 of How to Run C/C++ Program in Netbeans on Windows
    Run the code by clicking the play button
    1. At the bottom your output should be there, followed by a message that reads "Run Successful" with total runtime of your program
      Picture 33 of How to Run C/C++ Program in Netbeans on Windows
Part 5 of 5:

Troubleshooting

  1. Picture 34 of How to Run C/C++ Program in Netbeans on Windows
    1. Be sure to install the Cygwin compiler and debugger first. It allows the IDE to auto-find it in your system
    2. If Cygwin does not appear in the tool collection field, be sure that its path is added to the Environment Variables
    3. If the project does not build or run correctly, be sure to look carefully at the final screenshot and make sure that all parts in the text editor look the same
Update 05 March 2020
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile