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

The NetBeans IDE is a dynamic modular IDE, which means you can change it by adding and removing modules of the program. You can add functionality by installing plugin modules, or remove functionality by uninstalling plugin modules. If your...

Part 1 of 3:

If you have NetBeans IDE 8.0 without the C/C++ plugin

If your NetBeans IDE does not show a C/C++ project category when you select File > New Project, complete the following steps to add the C/C++ plugin module to the IDE.

  1. Picture 1 of How to Run Program C/C++ Program in Netbeans
    If your network uses a proxy, choose Tools > Options > General in the IDE, select Manual Proxy Settings, enter the HTTP Proxy and Port for your proxy, and click OK.
  2. Picture 2 of How to Run Program C/C++ Program in Netbeans
    Choose Tools > Plugins.
  3. Picture 3 of How to Run Program C/C++ Program in Netbeans
    In the Plugins dialog box, click the Available Plugins tab, and scroll to the C/C++ category.
  4. Picture 4 of How to Run Program C/C++ Program in Netbeans
    Select the C/C++ checkbox and click Install to start the NetBeans IDE Installer.
  5. Picture 5 of How to Run Program C/C++ Program in Netbeans
    In the NetBeans IDE Installer, click Next.
  6. Picture 6 of How to Run Program C/C++ Program in Netbeans
    Read the license agreement, select the checkbox to accept the terms of the license agreement, and click Next.
  7. Picture 7 of How to Run Program C/C++ Program in Netbeans
    Click Install.
  8. Picture 8 of How to Run Program C/C++ Program in Netbeans
    After the installation completes, select either Restart IDE Now or Restart IDE Later and click Finish.
Part 2 of 3:

Installing and Setting Up the Compilers and Tools

  1. Picture 9 of How to Run Program C/C++ Program in Netbeans
    Compile. After installing the Plug-In, you then require a compiler for compiling C/C++ Codes. The NetBeans C/C++ module has been tested with compilers from Cygwin and MinGW. If you install both Cygwin and MinGW, be careful to keep their installation locations completely separate and do not mix tools from Cygwin and MinGW in one tool collection in the IDE. Install the GNU gcc and g++ compilers, make, and gdb debugger from cygwin.com as follows.
  2. Picture 10 of How to Run Program C/C++ Program in Netbeans
    Download the Cygwin setup-x86.exe (32-bit installation) or setup-x86_64.exe (64-bit installation) program by clicking Install Cygwin in the left navigation bar, or by clicking the direct setup-x86.exe or setup-x86_64.exe link. Note: The bits of Windows OS, Java, and NetBeans IDE installed on your machine must match. For example, if you are running the 64-bit version of Windows operating system, 64-bit Java and 64-bit Cygwin (that is setup-x86_64.exe) are required to be installed.
  3. Picture 11 of How to Run Program C/C++ Program in Netbeans
    Run the downloaded Cygwin installer. Accept the defaults until you reach the Select Your Internet Connection page. Select the option on this page that is best for you. Click Next.
  4. Picture 12 of How to Run Program C/C++ Program in Netbeans
    On the Choose Download Site page, choose a download site you think might be relatively close to you. Click Next.
  5. Picture 13 of How to Run Program C/C++ Program in Netbeans
    On the Select Packages page you select the packages to download. Click the + next to Level to expand the development tools category. You may want to resize the window so you can see more of it at one time.
  6. Picture 14 of How to Run Program C/C++ Program in Netbeans
    Select each package you want to download by clicking the Skip label next to it, which reveals the version number of the package to download. At a minimum, select The ones Outlined Below. Packages that are required by the packages you select are automatically selected as well.
    1. gcc-core: C compiler
    2. gcc-g++: C++ compiler
    3. gdb: The GNU Debugger
    4. make: the GNU version of the 'make' utility
  7. Picture 15 of How to Run Program C/C++ Program in Netbeans
    Click Next to connect to the download site and download the packages you selected, and click Finish when the installation is complete.
  8. Picture 16 of How to Run Program C/C++ Program in Netbeans
    Now add the Cygwin compiler directory to your path to enable NetBeans IDE to find the tools collection:
    1. Open the Control Panel: - On Windows XP select Start > Settings > Control Panel and double-click System. - On Windows 7, type var in the Start menu's search box to quickly find a link to Edit the system environment variables.
    2. Select the Advanced tab and click Environment Variables.
    3. In the System Variables panel of the Environment Variables dialog, select the Path variable and click Edit.
    4. Add the path to the cygwin-directorybin directory to the Path variable, and click OK. By default, cygwin-directory is C:cygwin (for 32 bit Cygwin distribution) or C:cygwin64 (for 64 bit Cygwin distribution). Directory names must be separated with a semicolon. Your edited path should look something like %SystemRoot%system32;%SystemRoot%;C:Program FilesQuickTimeQTSystem;C:cygwinbin
    5. Click OK in the Environment Variables dialog and the System Properties dialog.
    6. See Verifying the Installation to verify that the tools were installed correctly for the NetBeans IDE.
Part 3 of 3:

MinGW Compilers and Tools

NetBeans IDE 8.0 was tested with Minimalist GNU for Windows (MinGW) and the Minimal System (MSYS) Unix-like environment. Versions tested and installation instructions are shown below. To install the GNU compilers, make, and gdb debugger from mingw.org:

  1. Picture 17 of How to Run Program C/C++ Program in Netbeans
    Log in to Windows using an account with computer administrator privileges.
  2. Picture 18 of How to Run Program C/C++ Program in Netbeans
    Download the MinGW installer from http://sourceforge.net/projects/mingw.
  3. Picture 19 of How to Run Program C/C++ Program in Netbeans
    Run the MinGW installer, which should have a file name similar to mingw-get-setup.exe.
  4. Picture 20 of How to Run Program C/C++ Program in Netbeans
    Accept the default C:MinGW as the destination folder if possible to minimize any potential difficulty with using the compilers from another location.
  5. Picture 21 of How to Run Program C/C++ Program in Netbeans
    In the MinGW installer select the following components to install:
    1. mingw-developer-toolkit
    2. mingw32-base
    3. mingw32-gcc-fortran (if you will be working on Fortran programs)
    4. msys-base
    5. mingw32-gcc-g++
  6. Picture 22 of How to Run Program C/C++ Program in Netbeans
    Select Installation > Apply Changes from the main menu.
  7. Picture 23 of How to Run Program C/C++ Program in Netbeans
    Click Apply to confirm the installation and wait a few minutes while the installer program downloads the components you selected.
  8. Picture 24 of How to Run Program C/C++ Program in Netbeans
    You must add the paths to the the binaries for MinGW and MSYS tools to your PATH. If you installed to the default location the paths are C:MinGWbin and C:MinGWMSYS1.0bin.
    1. Click Close when the packages installation is completed.
Update 05 March 2020
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile