Difference between revisions of "Creating New Projects with Eclipse"

From wiki.emacinc.com
Jump to: navigation, search
Line 1: Line 1:
{{todo|Port this and finish it.|Michael Gloff|project=oe 4,InProgress,mg}}
+
{{todo|Port this and finish it. (11.8.2013-27:32->MG+) |Michael Gloff|project=oe 4,Review,ky,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 [[ Importing_the_EMAC_OE_SDK_Projects_with_Eclipse | imported ]].
+
The purpose of this guide is to demonstrate how to create a new projects in Eclipse using the EMAC Open Embedded SDK. This will include step-by-step procedures for creating both C/C++ projects and Qt based projects. This guide will assume that the SDK has already been [[ Installing_EMAC_OE_4.0_SDK | installed ]] and [[Configuring_EMAC_OE_4.0_SDK | configured ]].
<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>
 
<br clear=all>
Line 12: Line 10:
 
* [[ EMAC_OE_SDK_Introduction | EMAC OE SDK ]]
 
* [[ EMAC_OE_SDK_Introduction | EMAC OE SDK ]]
  
==New Project Setup==
+
==Creating a New SDK C Project==  
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 C Project==
 
 
 
<cl>
 
<cl>
1. Make sure that the SDK has been configured according to [[Configuring_EMAC_OE_4.0_SDK | Configuring the SDK ]]
+
1. Start Eclipse.
* Start Eclipse.
 
 
{{mbox | type=information | text = When Eclipse starts, the user will be prompted to choose a workspace location.  
 
{{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.}}
 
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.}}
Line 39: Line 32:
 
* Ensure that – Other Toolchain – is selected in the Toolchains: list.
 
* Ensure that – Other Toolchain – is selected in the Toolchains: list.
 
* Click the Finish button.
 
* Click the Finish button.
* Select Yes to open the C/C++ perspective if prompted
+
* Select Yes to open the C/C++ perspective if prompted.
  
 
[[File:Eclipse_new_project.png|600px|thumb|left|Figure 3: New Eclipse Project ]]
 
[[File:Eclipse_new_project.png|600px|thumb|left|Figure 3: New Eclipse Project ]]
Line 53: Line 46:
 
</cl>
 
</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 SDK 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''
 +
 +
[[File:Eclipse_new_source.png|600px|thumb|left|Figure 5: New Source File ]]
 +
 +
<br clear=all>
 +
 +
* 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 SDK New Project guide.
 +
* Save the file by selecting ''File->Save'' from the Eclipse menubar. See figure 16 for how Eclipse should look.
 +
 +
[[File:Eclipse_hello_new.png|400px|thumb|left|Figure 6: Eclipse Workspace]]
 +
 +
<br clear=all>
 +
</cl>
 +
 +
==Make file Setup==
 +
 +
Make files are used by Eclipse and tell it what source files to compile, what compiler to use and what actions to perform (targets). Common Makefile targets are ''all'', to compile and link all source files, ''clean'' removes all output files, and ''upload'' to  transfer the resulting executable to the target device.
 +
 +
===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 7: Make Target context menu ]]
 +
 +
<br clear=all>
 +
 +
* Create the make targets ''all, clean'' and ''upload'' as in figures 8,9 and 10.
 +
<gallery widths=300px heights=400px  mode="traditional">
 +
File:Make_new_all.png|Figure 8: Make New All Target
 +
File:Make_new_clean.png|Figure 9: Make New Clean Target
 +
File:Make_new_upload.png|Figure 10: 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 the GNU ''make'' utility 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.
 +
 +
===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. For a Qt project first run Project->Run qmake.  The project will now build, and your window should appear similar to figure 10.
 +
 +
:[[File:Eclipse hello project built.png|400px|thumb|left|Figure 11: 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.
 +
[[ Using_the_EMAC_OE_SDK_Projects_with_Eclipse#EMAC_SDK_Example:_Compile_and_Run_the_hello_Project | Compile and Run ]] procedure from the Eclipse
 
==Creating a New SDK QT Project==
 
==Creating a New SDK QT Project==
  
Line 58: Line 118:
  
 
<cl>
 
<cl>
1. Make sure that the SDK has been configured according to [[Configuring_EMAC_OE_4.0_SDK | Configuring the SDK ]]
+
1. Start Eclipse.
* Start Eclipse.
 
 
* From the Eclipse menubar, select File->New->Project
 
* From the Eclipse menubar, select File->New->Project
 
* Under Qt, select Qt Gui Project or Qt Console Project then click Next
 
* Under Qt, select Qt Gui Project or Qt Console Project then click Next
  
[[File:New_qt_project.png|600px|thumb|left|Figure 5: New Qt Project ]]
+
[[File:New_qt_project.png|600px|thumb|left|Figure 12: New Qt Project ]]
  
 
<br clear=all>
 
<br clear=all>
Line 71: Line 130:
 
{{mbox | type=information | text = Make sure that the Location is set to the /path/to/sdk/projects folder as noted above.}}
 
{{mbox | type=information | text = Make sure that the Location is set to the /path/to/sdk/projects folder as noted above.}}
  
[[File:New_qt_gui_project.png|600px|thumb|left|Figure 6: New Qt Project ]]
+
[[File:New_qt_gui_project.png|600px|thumb|left|Figure 13: New Qt Project ]]
  
 
<br clear=all>
 
<br clear=all>
Line 77: Line 136:
 
* Accept the default file names for the project and click Next
 
* Accept the default file names for the project and click Next
  
[[File:New_qt_project_pg2.png|600px|thumb|left|Figure 7: New Qt Project ]]
+
[[File:New_qt_project_pg2.png|600px|thumb|left|Figure 14: New Qt Project ]]
  
 
<br clear=all>
 
<br clear=all>
Line 83: Line 142:
 
* Select any additional Qt modules that are required for the project, then click Finish
 
* Select any additional Qt modules that are required for the project, then click Finish
  
[[File:New_qt_gui_project_pg3.png|600px|thumb|left|Figure 8: New Qt Project ]]
+
[[File:New_qt_gui_project_pg3.png|600px|thumb|left|Figure 15: New Qt Project ]]
  
 
<br clear=all>
 
<br clear=all>
Line 97: Line 156:
 
<cl>
 
<cl>
 
1. Open a Qt Gui project or create one as above.
 
1. Open a Qt Gui project or create one as above.
* Double click on the myproject.ui file in the Project Explorer pane. This will open the Qt Designer Editor window. See figure 9.
+
* Double click on the myproject.ui file in the Project Explorer pane. This will open the Qt Designer Editor window. See figure 15.
  
[[File:Eclipse_qt_designer_new_ui.png|600px|thumb|left|Figure 9: Eclipse Qt Designer Editor window ]]
+
[[File:Eclipse_qt_designer_new_ui.png|600px|thumb|left|Figure 16: Eclipse Qt Designer Editor window ]]
  
 
<br clear=all>
 
<br clear=all>
  
 
* The properties for the project can be modified in the right hand pane Qt C++ Property Editor tab.
 
* The properties for the project can be modified in the right hand pane Qt C++ Property Editor tab.
** The geometry of the project window can be set here or by dragging the handles in the editor window.
+
* The geometry of the project window can be set here or by dragging the handles in the editor window.
** 480x272 is the correct resolution for EMAC's 4.3" display
+
* 480x272 is the correct resolution for EMAC's 4.3" display
  
[[File:Eclipse_qt_designer_geometry.png|600px|thumb|left|Figure 10: Qt Designer Geometry Properties ]]
+
[[File:Eclipse_qt_designer_geometry.png|600px|thumb|left|Figure 17: Qt Designer Geometry Properties ]]
  
 
<br clear=all>
 
<br clear=all>
Line 113: Line 172:
 
The QT C++ Widget Box allows the user to drag and drop components (buttons, textboxes, labels...) onto the editor.
 
The QT C++ Widget Box allows the user to drag and drop components (buttons, textboxes, labels...) onto the editor.
 
* To show the editor:
 
* To show the editor:
** On the Eclipse menubar click Window->Show View->Other...
+
* On the Eclipse menubar click Window->Show View->Other...
 +
* Under QT, select Qt C++ Widget Box then click OK
  
[[File:Eclipse_qt_widget_box.png|600px|thumb|left|Figure 11: Qt Designer Geometry Properties ]]
+
[[File:Eclipse_qt_widget_box.png|600px|thumb|left|Figure 18: Qt Designer Geometry Properties ]]
  
 
<br clear=all>
 
<br clear=all>
  
 
</cl>
 
</cl>
 
==Make file 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 12: Make Target context menu ]]
 
 
<br clear=all>
 
 
* Create the make targets ''all, clean'' and ''upload'' as in figures 13,14 and 15.
 
<gallery widths=300px heights=400px  mode="traditional">
 
File:Make_new_all.png|Figure 13: Make New All Target
 
File:Make_new_clean.png|Figure 14: Make New Clean Target
 
File:Make_new_upload.png|Figure 15: 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 samalt texte 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==
 
==Alternate Project Locations==
Line 158: Line 189:
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
cp -L /path/to/sdk/projects/global.properties /path/to/project/hello
+
developer@ldc:~$ cp -L /path/to/sdk/projects/global.properties /path/to/project/hello
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 170: Line 201:
 
</cl>
 
</cl>
  
==Using the New Project==
+
Old pages:
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>
+
http://wiki.emacinc.com/doku.php?id=linux:eclipse:newproject
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 16 for how Eclipse should look.
 
  
[[File:Eclipse_hello_new.png|400px|thumb|left|Figure 16: Eclipse Workspace]]
+
http://wiki.emacinc.com/doku.php?id=linux:eclipse:newsdkproject
  
<br clear=all>
+
http://wiki.emacinc.com/doku.php?id=linux:eclipse:example
</cl>
 
  
===Cross-Compile===
+
http://wiki.emacinc.com/doku.php?id=linux:ldc:eclipse#creating_eclipse_make_targets
To build the project, ensure the project is highlighted in the Project Explorer treeview in the left pane, then select Project->Build Project. For a Qt project first run Project->Run qmake. The project will now build, and your window should appear similar to figure 17.
 
  
:[[File:Eclipse hello project built.png|400px|thumb|left|Figure 17: Eclipse Workspace]]
+
==See Also==
 
 
<br clear=all>
 
 
 
If there are any build errors, they will be shown in the ''Console'' and/or ''Problems'' tabs on the bottom.
 
  
 +
[http://www.eclipse.org/documentation/ '''Eclipse Documentation''']
  
Old pages:
+
[http://qt-project.org/doc/ '''QT Documentation''']
http://wiki.emacinc.com/doku.php?id=linux:eclipse:newsdkproject
 
http://wiki.emacinc.com/doku.php?id=linux:eclipse:example
 
==See Also==
 
[http://www.eclipse.org/documentation/ Eclipse Documentation]
 
[http://qt-project.org/doc/ QT Documentation]
 
  
[[ 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]]
 
[[Category:EMAC Eclipse]]

Revision as of 20:53, 8 November 2013

TODO: {{#todo:Port this and finish it. (11.8.2013-27:32->MG+) |Michael Gloff|oe 4,Review,ky,mg}}

The purpose of this guide is to demonstrate how to create a new projects in Eclipse using the EMAC Open Embedded SDK. This will include step-by-step procedures for creating both C/C++ projects and Qt based projects. This guide will assume that the SDK has already been installed and configured .


Required Tools

Creating a New SDK C Project

  1. Start Eclipse.

    Figure 1: Select Eclipse Workspace


  2. From the Eclipse menubar, select File->New->Project

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

    Figure 2. Open C Project


  4. Enter “hello” in the Project name: field.

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

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

  7. Click the Finish button.

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

    Figure 3: New Eclipse Project


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

    Figure 4: New Eclipse Project



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 SDK 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

    Figure 5: New Source File


  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 SDK New Project guide.

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

    Figure 6: Eclipse Workspace


Make file Setup

Make files are used by Eclipse and tell it what source files to compile, what compiler to use and what actions to perform (targets). Common Makefile targets are all, to compile and link all source files, clean removes all output files, and upload to transfer the resulting executable to the target device.

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 7: Make Target context menu


  4. Create the make targets all, clean and upload as in figures 8,9 and 10.


Modify the Makefile

Once the Make Targets have been created, a Makefile needs to be created that contains the same targets so the GNU make utility 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.

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. For a Qt project first run Project->Run qmake. The project will now build, and your window should appear similar to figure 10.

Figure 11: Eclipse Workspace


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

Creating a New SDK QT Project

The process for creating a new QT project is similar to creating a new C project with some minor differences.


  1. Start Eclipse.

  2. From the Eclipse menubar, select File->New->Project

  3. Under Qt, select Qt Gui Project or Qt Console Project then click Next

    Figure 12: New Qt Project


  4. Enter myproject in the Project Name: field and click Finish.

    Figure 13: New Qt Project


  5. Accept the default file names for the project and click Next

    Figure 14: New Qt Project


  6. Select any additional Qt modules that are required for the project, then click Finish

    Figure 15: New Qt Project



The project is now set up and ready to begin coding an application. For more information on creating Qt applications see Getting Started Programming with Qt on the Qt website.

QT GUI Project

The Eclipse IDE contains a graphical editor for creating GUI applications. The following will show the steps for using the Qt Designer Editor.


  1. Open a Qt Gui project or create one as above.

  2. Double click on the myproject.ui file in the Project Explorer pane. This will open the Qt Designer Editor window. See figure 15.

    Figure 16: Eclipse Qt Designer Editor window


  3. The properties for the project can be modified in the right hand pane Qt C++ Property Editor tab.

    • The geometry of the project window can be set here or by dragging the handles in the editor window.

    • 480x272 is the correct resolution for EMAC's 4.3" display

    Figure 17: Qt Designer Geometry Properties


    The QT C++ Widget Box allows the user to drag and drop components (buttons, textboxes, labels...) onto the editor.

  4. To show the editor:

    • On the Eclipse menubar click Window->Show View->Other...

    • Under QT, select Qt C++ Widget Box then click OK

    Figure 18: Qt Designer Geometry Properties



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

    developer@ldc:~$ 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.


Old pages:

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

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

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

http://wiki.emacinc.com/doku.php?id=linux:ldc:eclipse#creating_eclipse_make_targets

See Also

Eclipse Documentation

QT Documentation