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

HOWTO Create Projects in NetBeans, and Compile & Execute Code

Create an ECE70 Directory on your USB/Flash Drive

Before you create your first project, you must create an ECE70 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 ECE70 subdirectory on your USB drive.
4.  Unclick the Create Main File box.
Verify the Build Host: is ece70k[XX]@ezekiel.engr.csufresno.edu, where [XX] is your login number.
6.  Verify the Tool Collection: is Default (GNU (GNU Compiler Collection)),
and click Finish.
5.  In the Projects window, right click on Source Files, and click on New -> C Source File. Type in the name of your new source file (hw[x], where [x] is your homework number) under File Name: and click Finish.

You may now begin coding your project.

Including the Math Library into the Linker

If your program requires the use of the math library, you must add the -lm option to the linker:

1.  Click on Run -> Set Project Configuration -> Customize... .
2.  Under the Build category, click on C Compiler, and under Additional Options click on ... to bring up the options window.
3.  Type -lm in the Additional options: window and hit OK. Click OK again to exit the customization options for the compiler.

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.