optics.csufresno.edu Class Files - ECE 71 HOWTOs
Department of Electrical and Computer Engineering
Dr. Gregory R. Kriehn, Professor

HOWTO Create Projects in NetBeans, and Compile & Execute Code

Create an ECE71 Directory on your USB/Flash Drive

Before you create your first project, you must create an ECE71 directory on your USB/Flash drive.

  This step only need to be performed once
before you create your first project. In the future you can skip to the next section, Creating a New Project in NetBeans.

Creating a New Project in NetBeans

To create a new project in NetBeans:

1.  Click on File -> New Project.
2.  Make sure C/C++ is selected under Categories:, and click on C/C++ Application under Projects:. Click Next>.
2.  Choose an appropriate Project Name: (i.e., HW[X], where [X] is the current homework number you are working on.)
3.  Under Project Location, click on Browse... and choose your ECE71 subdirectory on your USB drive.
4.  Ensure that the Create Main File box is clicked, and choose C++11 from the drop down menu to create the appropriate C++11 main.cpp file.
Verify the Build Host: is ece71k[XX]@ezekiel.engr.csufresno.edu, where [XX] is your login number.
6.  Verify the Tool Collection: is Default (GNU (GNU)),
and click Finish.
5.  In the Projects window, double click on Source Files, and double click on main.cpp to open your source file.

You may now begin coding your project.

Including Additional Warnings from the GCC Compiler

To add more warnings from the gcc compiler:

1.  Click on Run -> Set Project Configuration -> Customize... .
2.  Under the Build category, click on C++ Compiler.
3.  Under Warning Level choose More Warnings from the drop down menu.

Choosing this option is the same as adding the -Wall flag to the linker under Additional Options. If you click on ... under Additional Options you will now see the -Wall flag added to the compiler. I highly recommend using the -Wall option when compiling your programs, as it provides additional feedback if there is problem when gcc tries to compile your code.

4.  Click OK to exit the customization options.

Compiling and Executing Code in NetBeans

After you have finished coding, you can compile your code by clicking on the Build Main Project button (the hammer icon). Alteratively, press F11. Notice that NetBeans automatically copies all of your source files over to a temporary directory on the server, logs into the server, and then tries to compile it. If you are prompted for a password when you click the Build Main Project button, type it in and press Enter.

If you want to delete all temporary files in your project, and build your program from scratch, click on the Clean and Build Main Project button (the broom and hammer icon). Alternatively, press Shift+F11.

If your project compiles successfully, click the Run Main Project button (the green arrow). Alternatively, press F6.

Since the Run Main Project button (the green arrow) also compiles your code, you can press this button the first time you compile your code if you are reasonably certain your program's syntax is correct. Most of the time, however, it is wise to first debug your program and ensure it compiles correctly before attempting to execute the code.