Installing and Configuring C/C++ Support

Contributed and maintained by Ann Rice
October 2007
[Revision number: V6.0-1]

This document provides information on downloading, installing, and configuring C/C++ support in the NetBeans IDE.

Contents

Downloading C/C++ Support
Installing and Setting Up the Compilers and Tools
Verifying the Installation
  Content on this page applies to NetBeans IDE 6.0

Downloading C/C++ Support


If you do not have the NetBeans 6.0 IDE, go to the NetBeans IDE 6.0 Download Page, and download a version of the IDE that contains C/C++ support. If you have a NetBeans IDE 6.0 installation that does not include C/C++ support, complete the following steps to add C/C++ support to the IDE.

  1. If your network uses a proxy, choose Tools > Options from the main menu, select Manual Proxy Settings, enter the HTTP Proxy and Port for your proxy, and click OK.
  2. Choose Tools > Plugins from the main menu.
  3. In the Plugins dialog box, click the Available Plugins tab, and scroll to the C/C++ category.
  4. Select the C/C++ checkbox.
  5. Click Install.

    The NetBeans IDE Installer starts.
  6. In the NetBeans IDE Installer, click Next.
  7. Read the license agreement, then select the I Accept the Terms in All License Agreements radio button, and click Next.
  8. Click Install.
  9. After the installation completes, select either Restart IDE Now or Restart IDE Later and click Finish.

Installing and Setting Up the Compilers and Tools

Netbeans C/C++ pack requires a C compiler, C++ compiler, make utility, and gdb debugger.

Windows

NetBeans C/C++ pack has been tested with the following compilers and tools:

If you already have the Cygwin GNU compilers, GNU make, and gdb debugger installed on your Windows system and your path is set up correctly to find them, make sure that you have the correct versions. If you have the correct versions, then no further setup is necessary.

To check the versions of your Cygwin compilers and tools:

  1. Check the version of Cygwin by typing:

    cygcheck -c cygwin
    
  2. Check the versions of the compilers, make, and gdb by typing:
    gcc --version
    g++ --version
    make --version
    gdb --version
    

To install the GNU compilers, make, and gdb debugger from cygwin.com:

  1. Download the Cygwin setup.exe program by clicking the Install or Update Now! icon in the middle of the page.
  2. Run the setup.exe program. 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.
  3. On the Choose Download Site page, choose a download site you think might be relatively close to you. Click Next.
  4. On the Select Packages page you select the packages to download. Click the + next to Devel to expand the development tools category. You may want to resize the window so you can see more of it at one time.
  5. Select each package you want to download by clicking the Skip label next to it. At a minimum, select gcc-core: C compiler, gcc-g++: C++ compiler, gdb: The GNU Debugger, and make: the GNU version of the 'make' utility.
  6. Now add the Compiler directory to your path:

    1. Open the Control Panel (Start > Settings > Control Panel) and double-click the System program.
    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-directory\bin directory to the Path variable, and click OK. By default, cygwin-directory is C:\cygwin. Directory names must be separated with a semicolon.
    5. Click OK in the Environment Variables dialog and the System Properties dialog.

top


Solaris OS

NetBeans C/C++ pack has been tested with the following compilers and tools:

Sun Studio 12 Compilers

If you want to use the Sun Studio 12 compilers:

To download and install the Sun Studio 12 compilers:

  1. Create a directory for the downloaded file. You must have write permission for this directory.
  2. Download the file for your platform into the download directory.
  3. Go to the download directory, and uncompress and untar the downloaded file.
    bzcat filename | tar xvf -
    
  4. Follow the instructions in Chapter 2 of the Sun Studio 12 Quick Installation (English, Japanese, Simplified Chinese) guide to install the C compiler, C++ compiler, and required Solaris patches.

Add the path to the Sun Studio software to your PATH before starting the NetBeans IDE.

GNU Compilers and GNU make

If you want to use the GNU compilers and GNU make:

To download and install the GNU compilers and make

  1. Download gcc 3.4.6 and make 3.81.
  2. If the download zip files are not automatically gunzipped during download, unzip them with gunzip.
  3. Install the packages with the pkgadd command.

Make sure to include the GNU compiler directory and the GNU make directory in your path before starting the NetBeans IDE.

gdb Debugger

Whether you use the Sun Studio compilers and Solaris make or the GNU compilers and GNU make, you must have the gbd debugger to debug applications in NetBeans C/C++ Development Pack. You can download gdb 6.6 from http://www.sun.com/software/solaris/freeware/s10pkgs_download.xml.

To download and install gdb:

  1. Under "Select a Download" at the botttom of the page, select the Solaris 10 Companion Software download for your Solaris platform.
  2. On the Download page, accept the License Agreement and select the gbd - GNU source level debugger package.
  3. Become root (superuser).
  4. Unzip the file with binzip and install gbd with pkgadd:
    bunzip SFWgdb.bz2
    pkgadd -d SFWgbd
    

Make sure to include the path to gdb in your path before starting the NetBeans IDE.


top


Linux

NetBeans C/C++ pack has been tested with the following compilers and tools:

To download and install the Sun Studio 12 compilers:

  1. Create a directory for the downloaded file. You must have write permission for this directory.
  2. Download the file for your platform into the download directory.
  3. Go to the download directory, and uncompress and untar the downloaded file.
    bzcat filename | tar xvf -
    
  4. Follow the instructions in Chapter 2 of the Sun Studio 12 Quick Installation guide to install the C compiler, C++ compiler, and required Solaris patches.

Add the path to the Sun Studio software to your PATH before starting the NetBeans IDE.


top


Macintosh OS X

NetBeans C/C++ pack has been tested with the following compilers and tools:

Install the following packages that are provided with your Macintosh OS X:

Start the X11 server on your system prior to developing C/C++ applications with NetBeans.

top


Verifying the Installation

To verify that the installation is correct, start the NetBeans IDE, build a sample project, and run it in the gdb debugger.

Windows

To start the IDE on Microsoft Windows machines, do one of the following:

To build a sample project and run it in the debugger:

  1. Open the New Project wizard by choosing File > New Project.
  2. In the Categories panel on the Choose Project page of the wizard, expand the Samples category and the C/C++ Development subcategory, and select the C/C++ subcategory.
  3. In the Projects panel, select the Welcome project. Click Next.
  4. On the Project Name and Location page, click Finish.
  5. In the Projects tab of the IDE, right-click the Welcome_1 project and choose Build Project. If your compilers and make utility are installed correctly and the path to them is set, build output is displayed in the Output window and the project builds successfully.
  6. Double-click the welcome.cc file to open it in the Source Editor.
  7. Right-click in the left margin of the Source Editor window and choose Show Line Numbers.
  8. Set a breakpoint by clicking in the left margin of the Source Editor window next to line 33.

  9. Right-click the project and choose Debug Project. If the gdb debugger is installed correctly and the path to it is set, gdb starts up, the Debugger tabs are displayed, and the Welcome application runs and stops at the breakpoint.
  10. Choose Run > Continue to run the application to completion.

top


Solaris OS

To start the NetBeans IDE on Solaris systems:

  1. Navigate to the bin subdirectory of your installation.
  2. Execute the launcher script by typing ./netbeans.

To build a sample project and run it in the debugger:

  1. Open the New Project wizard by choosing File > New Project.
  2. In the Categories panel on the Choose Project page of the wizard, expand the Samples category and the C/C++ Development subcategory, and select the C/C++ subcategory.
  3. In the Projects panel, select the Welcome project. Click Next.
  4. On the Project Name and Location page, click Finish.
  5. In the Projects tab of the IDE, right-click the Welcome_1 project and choose Properties.
  6. In the Project Properties dialog box, set the Compiler Collection property to the compiler collection you want to validate and click OK.
  7. In the Projects tab, right-click the project and choose Build Project. If your compilers and make utility are installed correctly and the path to them is set, build output is displayed in the Output window and the project builds successfully.
  8. Double-click the welcome.cc file to open it in the Source Editor.
  9. Right-click in the left margin of the Source Editor window and choose Show Line Numbers.
  10. Set a breakpoint by clicking in the left margin of the Source Editor window next to line 33.
  11. Right-click the project and choose Debug Project. If the gdb debugger is installed correctly and the path to it is set, gdb starts up, the Debugger tabs are displayed, and the Welcome application runs and stops at the breakpoint.
  12. Choose Run > Continue to run the application to completion.

top


Linux

To start the NetBeans IDE on Linux systems:

  1. Navigate to the bin subdirectory of your installation.
  2. Execute the launcher script by typing ./netbeans.

To build a sample project and run it in the debugger:

  1. Open the New Project wizard by choosing File > New Project.
  2. In the Categories panel on the Choose Project page of the wizard, expand the Samples category and the C/C++ Development subcategory, and select the C/C++ subcategory.
  3. In the Projects panel, select the Welcome project. Click Next.
  4. On the Project Name and Location page, click Finish.
  5. In the Projects tab of the IDE, right-click the Welcome_1 project and choose Properties.
  6. In the Project Properties dialog box, set the Compiler Collection property to the compiler collection you want to validate and click OK.
  7. In the Projects tab, right-click the project and choose Build Project. If your compilers and make utility are installed correctly and the path to them is set, build output is displayed in the Output window and the project builds successfully.
  8. Double-click the welcome.cc file to open it in the Source Editor.
  9. Right-click in the left margin of the Source Editor window and choose Show Line Numbers.
  10. Set a breakpoint by clicking in the left margin of the Source Editor window next to line 33.
  11. Right-click the project and choose Debug Project. If the gdb debugger is installed correctely and the path to it is set, gdb starts up, the Debugger tabs are displayed, and the Welcome application runs and stops at the breakpoint.
  12. Choose Run > Continue to run the application to completion.

top


Mac OS X

To start the IDE on Macintosh machines, double-click the NetBeans icon on your desktop.

To build a sample project and run it in the debugger:

  1. Open the New Project wizard by choosing File > New Project.
  2. In the Categories panel on the Choose Project page of the wizard, expand the Samples category and the C/C++ Development subcategory, and select the C/C++ subcategory.
  3. In the Projects panel, select the Welcome project. Click Next.
  4. On the Project Name and Location page, click Finish.
  5. In the Projects tab of the IDE, right-click the Welcome_1 project and choose Build Project. If your compilers and make utility are installed correctly and the path to them is set, build output is displayed in the Output window and the project builds successfully.
  6. Double-click the welcome.cc file to open it in the Source Editor.
  7. Right-click the project and choose Debug Project. If the gdb debugger is installed correctly and the path to it is set, gdb starts up and the Debugger tabs are displayed.

top


Next Steps

To learn quickly how to develop a C or C++ application with the NetBeans IDE, see the C/C++ Support Quick Start Tutorial