0167 Using CPP With Netbeans
0167 Using CPP With Netbeans
For Introduction to Programming With C++
NOTE: This tutorial is for experience users to develop C++ programs using NetBeans.
To use C++ with NetBeans, you have to download and install a C++
compiler and NetBeans.
NetBeans can work with any C++ compiler. In this tutorial, we will
use the Cygwin compiler.
Click
sttup.exe
Figure 1
Download setup.exe to install a C++ compiler.
Figure 2
You need to save setup.exe and then run it.
Figure 3
Run setup.exe to start setup.
Figure 4
The setup program will install a C++ compiler.
4. From the Tools menu, choose Options to display the Options dialog
box, as shown in Figure 7. Click C/C++. In the C/C++ page, click
the Add button to display the Add New Tool Collection dialog box,
as shown in Figure 8.
Figure 7
Click the Add button to add a new tool.
Figure 8
Browse for c:\cygwin\bin to set it as the Base Directory.
Figure 9
The compiler and other supporting commands are set in the option.
1. Now you can create a C++ project to hold C++ programs. Choose
File, New Project to display the New Project dialog box. Choose
C/C++ in the Category section and choose C/C++ Application in the
Projects section and click Next to display the New C/C++
Application dialog box, as shown in Figure 10.
Figure 10
The New C/C++ Application dialog box creates a new project for
C/C++ applications.
Figure 11
A new project for C/C++ Applications is created.
2. Enter a project name (e.g., cs2490) in the Project Name field and
click Finish to create a project, as shown in Figure 11.
Figure 13
Enter a file name to create a .cpp file.
#include <iostream>
using namespace std;
int main()
{
cout << "Enter the radius and length of a cylinder: ";
double radius, length;
cin >> radius >> length;
return 0;
}
5. Before you can run this program, you need to remove main.cpp from
the project, because the project can have only one file with a
main function. Right-click on main.cpp and choose Remove From
Project to remove it, as shown in Figure 14.
6. Right-click on the project node cs2490 to run the project.
Figure 14
You can remove a file from the project.