Creating New Projects with Eclipse

From wiki.emacinc.com
Jump to: navigation, search
TODO: {{#todo:SEOKWREV Port this and finish it. (11.11.2013-11:52->KY+)(11.12.2013-10:47->JG+);(03.04.14-16:45->BS-);(03.25.14-16:00->BS+)|Michael Gloff|oe 4,SEOKWREV,ky,mg,bs}}

The purpose of this guide is to demonstrate how to create 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 in 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 6 for how Eclipse should look.

    Figure 6: Eclipse Workspace


Make file Setup

Make files are used by Eclipse to 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 11.

Figure 11: Eclipse Workspace


Any build errors will be displayed in the Console and/or Problems tabs at the bottom of the Eclipse window.

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 16.

    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 Makefile and the path to the SDK in the 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.


See Also