+ -
当前位置:首页 → 问答吧 → 建立一个简单的 Eclipse Project

建立一个简单的 Eclipse Project

时间:2007-03-03

来源:互联网

At this point, we have a fully-functioning Eclipse IDE capable of building C/C++ programs for the ARM microprocessor (specifically for the Olimex LPC-P2106 prototype board).


We will now create an Eclipse C project called “demo2106_blink_flash” that will blink the board’s red LED_J which is I/O port P0.7. This demo uses no interrupts and runs totally out of onboard flash memory. It has been intentionally designed to be as simple and as straightforward as possible.

Click on our Eclipse desktop icon to start Eclipse.

Eclipse should start and present the C/C++ perspective as shown below. If not, select “Window - Open Perspective – Other - C/C++” to change to the C++ perspective.

To create a project, select File – New – New Project - Standard Make C Project from the File pull-down menu and click “Next” to continue.

You should see the “New Project” dialog box and enter the project name (demo2106_blink_flash) in the box as shown below. Click on Next to continue.

The New Project dialog box appears next. If you click on the “Make Builder” tab, you’ll notice that Eclipse build command is “make.” Make is provided by the Cygwin GNU tools.

Let’s remind ourselves that we installed the Cygwin GNU tools earlier in the tutorial and the Windows Explorer will show that the make.exe file is indeed in the directory c:/cygwin/bin, as shown below.

Take the default on the “Build Command”, Eclipse will always issue a “make” command to build your project.

These are the targets that “make” will run when you hit the Build All, Build Project or Clean toolbar buttons.


This is a good time to point out the differences between “Build All”, “Build Project” and “Clean.”


Build All Will execute the command “make clean all.”

It will first clean (delete) all object, list and output files.

Then it will rebuild everything, whether needed or not.



Build Project Will execute the command “make all.”

This will not clean (delete) anything.

It will only compile those source files that are “out-of-date.”



Clean Will execute the command “make clean.”

Will clean (delete) all object, list and output files.

This is no different from opening up a DOS command window and typing the command in directly, such as.


> make clean all










If you click “Finish” on the “New Project” dialog, Eclipse will return to the C/C++ Perspective.


Now the C/C++ perspective shows a bona fide project in the “C/C++ projects” box on the left. As of now, there are no source files created.


We can now use Eclipse/CDT’s import feature to copy the source files into the project.

Assuming that you successfully unzipped the “demo2106_blink_flash.zip” project files associated with this tutorial to an empty directory such as c:/scratch, you should have the following source and make files in that directory.

Click on the “File” pull-down menu and then click on “Import.” Then in the “Import” window, click on “File System.”

When the “Import – File System” window appears, click on the “Browse” button. Hunt for the sample project which is stored in the c:/scratch/ directory.

Click on the directory “scratch” and hit the “OK” button in the “Import from directory” window on the left below.

Click on “Select All” in the Import window below right to get the source files selected for import into our project.

Now we have to indicate the destination for our source files. Click on “Browse” on the line to the right that says “Into Folder:”

The proper destination folder appears in the Import Into Folder window below.


Click on the folder name “demo2106_blink_flash” and click “OK.” The directory name “demo2106_blink_flash” should appear in the text box.
Now the Import dialog is completely filled out; we can click on “finish” to actually import the source files into our project.
Now the C/C++ perspective main screen will reappear. Click on the “+” expand symbol in the navigator pane to see if our files have been transferred.

Success is at hand, the expanded Projects view in the Navigator pane on the left shows our imported files.

This is a good place to identify the imported source files.



Description of Project Files


lpc210x.h
Standard LPC2106 header file

crt.s
Startup assembler file

main.c
Main C program

makefile
GNU makefile

demo2106_blink_flash.cmd
GNU Linker script file      

作者: wdefu   发布时间: 2007-03-03