Using the EMAC OE SDK Projects with Eclipse

From wiki.emacinc.com
Revision as of 19:33, 23 December 2013 by Mgloff (talk | contribs)
Jump to: navigation, search
TODO: {{#todo:Completed; (10.29.13-22:40->MD+)(11.06.13-15:20->JG+)|Klint Youngmeyer|oe 4,oe 5,ky,Complete, md}}

The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This guide demonstrates the process of compiling one of the example projects and running it on the target machine using the Eclipse IDE. A basic familiarity with Eclipse is assumed for this guide. For a quick intro see the First Time Starting Eclipse.

Tools Required

  • GNU make
  • EMAC OE SDK
  • wput

EMAC SDK Example: Compile and Run the hello Project

Setup

  1. Modify global.properties according to the SDK Remote Upload Setup to provide make with the correct user, password, and IP address for the upload target.
  2. Create a remote terminal connection. This is necessary to use the Remote System Explorer's SSH Terminal feature in the following procedure.

Create a new Makefile-based project

  1. Click Window → Open Perspective → Other... To bring up a dialog window with a list of Perspectives to choose from.

  2. Choose C/C++ and click Ok.

  3. Select File→New→Makefile Project with Existing Code

  4. In the window that appears, click the Browse... button.


  5. Navigate to the location of the project. By default this is under the home directory in ~/EMAC-OE-arm-linux-gnueabi-SDK_4.0/projects/hello

  6. Click the OK button.


  7. Click the Finish button.


    The arrowhead to the left of hello indicates that the hello project is open. Click on the arrowhead to see the files in the project. Double click on the hello.c file to open it.

  8. To build the project, first 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 the screenshot below:

    Eclipse hello project built.png


    Any build errors will be shown in the Console and/or Problems tabs on the bottom.

Uploading the Project to the Target Machine

  1. Click on the Make Target view tab in the right hand pane. If it is not open, Click Window→Show View→Other... and select Make→Make Taget

  2. Right click on the Make Target view tab and choose New...

  3. Type upload as the Target name and click OK


  4. To upload the executable to the target machine right click on the upload target in the Make Targets window and select Build Target

    The binary executable should be uploaded to the target machine. If there is an error, check to make sure the wput command installed, and that it can be called from within the Eclipse IDE

  5. Now Connect to the target machine.

  6. Run the program as shown below using the remote terminal created in the Remote Terminal Setup Guide.

    Chmod run phello1.png


The following is a brief description of each command seen in the SSH Terminal window above:

  • cd /tmp: Change the current working directory to /tmp/.
  • ls -l: List the current working directory's contents with file permissions shown. Notice that root does not have execute permissions for the file hello.
  • chmod u+x hello: Give executable permissions to the owner of the hello file. Note that this assumes that the same user is used to log in through the SSH Terminal as was specified in 'global.properties according to Step 1 of the Setup for this guide--in this example, the user is root.
  • ls -l: List the current working directory's contents with file permissions shown to be sure that root now has execute permission. The new x indicates that root does now have execute permissions.
  • ./hello: Execute the binary. The output shown is a simple message printed to the screen, "Hello EMAC OE!".

EMAC SDK with Qt Example: Compile and Run the textedit Project

Importing the Project

This procedure provides an overview of how to compile and run Qt C++ applications in Eclipse.

  1. Click Window → Open Perspective → Other... To bring up a dialog window with a list of Perspectives to choose from.

  2. Choose Qt C++ and click Ok.

  3. Select File→Import...

  4. Expand Qt and select Qt Project

    Eclipse import project step1.png


  5. Click Next >, then click Browse...

  6. Navigate to the projects/qt_demos/textedit directory underneath the install location of the EMAC OE SDK.

  7. Highlight textedit.pro then click OK.

  8. Click Finish.

    Eclipse import project step2.png


Building the Project

The Project Explorer should now show the textedit project.

Eclipse textedit project selected.png


The arrowhead to the left of textedit indicates that the textedit project is open.

  1. Click on the arrowhead to see the files in the project.

  2. Double click on the textedit.cpp file to open it. The arrow next to textedit.cpp can be expanded to see a list of classes and functions available within this source file.

  3. To build the project, ensure the project is highlighted in the Project Explorer treeview in the left pane.

  4. Select Project→Run qmake

  5. Now, select Project→Build Project. The project will now build, and your window should appear similar to the screenshot below:

    Eclipse qt build textedit finished.png


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

Next Steps

The next step is to create a new New Project Guide | Makefile-based Eclipse project.