Difference between revisions of "Creating New Projects with Eclipse"

From wiki.emacinc.com
Jump to: navigation, search
m (Fixed TODO)
Line 1: Line 1:
{{todo|Port this and finish it.|Michael Gloff|project=oe 4,oe 5,mg}}
+
{{todo|Port this and finish it.|Michael Gloff|project=oe 4,mg}}
  
  see http://wiki.emacinc.com/doku.php?id=linux:eclipse:newsdkproject
+
The purpose of this guide is to demonstrate how to create a new project in Eclipse using the EMAC Open Embedded SDK. This will include a step-by-step procedure which assumes that the SDK has already been [[ Importing_the_EMAC_OE_SDK_Projects_with_Eclipse | imported ]].
 +
<br clear=all>
 +
Since this guide is specific to the EMAC OE SDK, it is not interchangeable with a general guide on creating a new Eclipse project.
 +
 
 +
<br clear=all>
 +
 
 +
==Required Tools==
 +
* GNU ''Make''
 +
* [[ EMAC_Eclipse_Introduction | EMAC Eclipse 3.6 ]]
 +
* [[ EMAC_OE_SDK_Introduction | EMAC OE SDK ]]
 +
 
 +
==New Project Setup==
 +
Before getting started creating a new project, the following setup must be performed. It is up to the application developer whether the new project will be placed in the EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects project folder in the Eclipse Project Explorer View or within its own project folder. The latter does involve more complexity during setup, though it is a bit neater to work with since it does not require the developer to navigate the SDK directory tree to get to the new project.
 +
Note that only one of the following subsections is necessary to move on to the General Setup Section.
 +
==Creating a New SDK Project==
 +
   
 +
<cl>
 +
1. Make sure that the SDK has been configured according to [[Configuring_EMAC_OE_4.0_SDK | Configuring the SDK ]]
 +
* Start Eclipse.
 +
{{mbox | type=information | text = When Eclipse starts, the user will be prompted to choose a workspace location.
 +
The recommended location is /path/to/sdk/projects. This will allow the user to easily leverage the use of the SDK. If a different location is chosen, see the section below on alternate project locations.}}
 +
 
 +
[[File:Select_workspace.png|400px|thumb|left|Figure 1: Select Eclipse Workspace]]
 +
 
 +
<br clear=all>
 +
 
 +
* From the workspace, select File->New->Project
 +
* Under C/C++, select C Project then next
 +
 
 +
[[File:Eclipse_new_C_project.png|600px|thumb|left|Figure 2. Open C Project]]
 +
 
 +
<br clear=all>
 +
 
 +
* In the C Project dialog window, enter “hello” in the Project name: field.
 +
* Scroll down and choose Makefile Project -> Empty Project in the Project type: list.
 +
* Ensure that – Other Toolchain – is selected in the Toolchains: list.
 +
* Click the Finish button.
 +
* Select Yes to open the C/C++ perspective if prompted
 +
 
 +
[[File:Eclipse_new_project.png|600px|thumb|left|Figure 3: New Eclipse Project ]]
 +
 
 +
<br clear=all>
 +
 
 +
* The workbench should look similar to Figure 4 below.
 +
 
 +
[[File:Eclipse_workbench.png|600px|thumb|left|Figure 3: New Eclipse Project ]]
 +
 
 +
<br clear=all>
 +
 
 +
</cl>
 +
 
 +
==General Setup==
 +
 
 +
===Generate Eclipse Make Targets===
 +
The following will demonstrate how to add the ''all'', ''clean'' and ''upload'' targets for ''make''
 +
 
 +
<cl>
 +
1. Click on the ''Make Target'' view tab in the right hand pane. 
 +
 
 +
{{mbox | type=information | text = If the ''Make Target'' tab is not visible, select Window -> Show View -> other... from the Eclipse toolbar. Then select Make -> Make Target.}}
 +
 
 +
* Right click on ''hello'' to bring up the context menu.
 +
* Select ''New...''
 +
 
 +
[[File:new_make_target3.png|600px|thumb|left|Figure 4: Make Target context menu ]]
 +
 
 +
<br clear=all>
 +
 
 +
* Create the make targets ''all, clean'' and ''upload'' as in figures 5,6 and 7.
 +
<gallery widths=300px heights=400px  mode="traditional">
 +
File:Make_new_all.png|Figure 5: Make New All Target
 +
File:Make_new_clean.png|Figure 6: Make New Clean Target
 +
File:Make_new_upload.png|Figure 7: Make New Upload Target
 +
</gallery>
 +
</cl>
 +
<br clear=all>
 +
 
 +
===Modify the Makefile===
 +
Once  the Make Targets have been created, a Makefile needs to be created that contains the same targets so that GNU make knows how to compile and link the source into a binary that will run on the target machine. See the [[Creating_a_New_EMAC_OE_SDK_Project#Modify_the_Makefile | Makefile modification section]] of the EMAC OE SKE New Project guide for more explanation.
 +
 
 +
==Alternate Project Locations==
 +
If the project is created outside of the /path/to/sdk/projects directory, the paths present in the make file and path to the SDK and global.properties files will need to be modified as below.
 +
 
 +
<cl>
 +
 
 +
1. Copy the correct global.properties file from the SDK/projects directory to the current project directory
 +
 
 +
<syntaxhighlight lang="bash">
 +
cp -L /path/to/sdk/projects/global.properties /path/to/project/hello
 +
</syntaxhighlight>
 +
 
 +
* Modify the include line at the top of the make file to refer to the new global.properties file
 +
<syntaxhighlight lang="console">
 +
include global.properties
 +
</syntaxhighlight>
 +
 
 +
* Change the value of <code>SDKBASE</code> in global.properties to point to the location of the SDK installation.
 +
 
 +
</cl>
 +
 
 +
==Using the New Project==
 +
The next step is to write some example C code for the project. See [[Creating_a_New_EMAC_OE_SDK_Project#Write_the_C_Code | Write the C Code]] section of the EMAC OE SKE New Project guide for more explanation.
 +
 
 +
<cl>
 +
1. Open the C/C++ Perspective if it is not open already.
 +
  i. From the Eclipse menubar, select ''Window -> Open Perspective -> Other...''
 +
  * Select C/C++ and click OK
 +
* Create a new C file using the Eclipse New Source Wizard.
 +
  i. From the Eclipse menubar, select ''File-> New-> Source File''.
 +
  * Set the ''Source File:'' field to hello.c
 +
  * Set the value of ''Template:'' to <None>
 +
  * Click ''Finish''
 +
* If the new C file did not open automatically, open it by double clicking hello.c the the left pane
 +
* Copy the code from Listing 1. in the [[Creating_a_New_EMAC_OE_SDK_Project#Write_the_C_Code | C code writing ]] section of the EMAC OE SKE New Project guide.
 +
* Save the file by selecting ''File->Save'' from the Eclipse menubar. See figure 8 for how Eclipse should look.
 +
 
 +
[[File:Eclipse_hello_new.png|400px|thumb|left|Figure 8: Eclipse Workspace]]
 +
 
 +
<br clear=all>
 +
</cl>
 +
 
 +
===Cross-Compile===
 +
To build the project, ensure the project is highlighted in the Project Explorer treeview in the left pane, then select Project->Build Project.  The project will now build, and your window should appear similar to figure 9.
 +
 
 +
:[[File:Eclipse hello project built.png|400px|thumb|left|Figure 9: Eclipse Workspace]]
 +
 
 +
<br clear=all>
 +
 
 +
If there are any build errors, they will be shown in the ''Console'' and/or ''Problems'' tabs on the bottom.
 +
 
 +
 
 +
see http://wiki.emacinc.com/doku.php?id=linux:eclipse:newsdkproject
 +
==See Also==
 +
[[ Using_the_EMAC_OE_SDK_Projects_with_Eclipse#EMAC_SDK_Example:_Compile_and_Run_the_hello_Project | Compile and Run ]] procedure from the Eclipse Example Project Guide to compile the project. Note: There may be differences between
 +
 
 +
[[Category:EMAC Eclipse]]

Revision as of 19:24, 30 October 2013

TODO: {{#todo:Port this and finish it.|Michael Gloff|oe 4,mg}}

The purpose of this guide is to demonstrate how to create a new project in Eclipse using the EMAC Open Embedded SDK. This will include a step-by-step procedure which assumes that the SDK has already been imported .
Since this guide is specific to the EMAC OE SDK, it is not interchangeable with a general guide on creating a new Eclipse project.


Required Tools

New Project Setup

Before getting started creating a new project, the following setup must be performed. It is up to the application developer whether the new project will be placed in the EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects project folder in the Eclipse Project Explorer View or within its own project folder. The latter does involve more complexity during setup, though it is a bit neater to work with since it does not require the developer to navigate the SDK directory tree to get to the new project. Note that only one of the following subsections is necessary to move on to the General Setup Section.

Creating a New SDK Project

  1. Make sure that the SDK has been configured according to Configuring the SDK

  2. Start Eclipse.

    Figure 1: Select Eclipse Workspace


  3. From the workspace, select File->New->Project

  4. Under C/C++, select C Project then next

    Figure 2. Open C Project


  5. In the C Project dialog window, enter “hello” in the Project name: field.

  6. Scroll down and choose Makefile Project -> Empty Project in the Project type: list.

  7. Ensure that – Other Toolchain – is selected in the Toolchains: list.

  8. Click the Finish button.

  9. Select Yes to open the C/C++ perspective if prompted

    Figure 3: New Eclipse Project


  10. The workbench should look similar to Figure 4 below.

    Figure 3: New Eclipse Project



General Setup

Generate Eclipse Make Targets

The following will demonstrate how to add the all, clean and upload targets for make


  1. Click on the Make Target view tab in the right hand pane.

  2. Right click on hello to bring up the context menu.

  3. Select New...

    Figure 4: Make Target context menu


  4. Create the make targets all, clean and upload as in figures 5,6 and 7.


Modify the Makefile

Once the Make Targets have been created, a Makefile needs to be created that contains the same targets so that GNU make knows how to compile and link the source into a binary that will run on the target machine. See the Makefile modification section of the EMAC OE SKE New Project guide for more explanation.

Alternate Project Locations

If the project is created outside of the /path/to/sdk/projects directory, the paths present in the make file and path to the SDK and global.properties files will need to be modified as below.


  1. Copy the correct global.properties file from the SDK/projects directory to the current project directory

    cp -L /path/to/sdk/projects/global.properties /path/to/project/hello
    
  2. Modify the include line at the top of the make file to refer to the new global.properties file

    include global.properties
    
  3. Change the value of SDKBASE in global.properties to point to the location of the SDK installation.


Using the New Project

The next step is to write some example C code for the project. See Write the C Code section of the EMAC OE SKE New Project guide for more explanation.


  1. Open the C/C++ Perspective if it is not open already.

    1. From the Eclipse menubar, select Window -> Open Perspective -> Other...

    2. Select C/C++ and click OK

  2. Create a new C file using the Eclipse New Source Wizard.

    1. From the Eclipse menubar, select File-> New-> Source File.

    2. Set the Source File: field to hello.c

    3. Set the value of Template: to <None>

    4. Click Finish

  3. If the new C file did not open automatically, open it by double clicking hello.c the the left pane

  4. Copy the code from Listing 1. in the C code writing section of the EMAC OE SKE New Project guide.

  5. Save the file by selecting File->Save from the Eclipse menubar. See figure 8 for how Eclipse should look.

    Figure 8: Eclipse Workspace


Cross-Compile

To build the project, ensure the project is highlighted in the Project Explorer treeview in the left pane, then select Project->Build Project. The project will now build, and your window should appear similar to figure 9.

Figure 9: Eclipse Workspace


If there are any build errors, they will be shown in the Console and/or Problems tabs on the bottom.


see http://wiki.emacinc.com/doku.php?id=linux:eclipse:newsdkproject

See Also

Compile and Run procedure from the Eclipse Example Project Guide to compile the project. Note: There may be differences between