Difference between revisions of "Using the EMAC OE SDK Projects with Eclipse"

From wiki.emacinc.com
Jump to: navigation, search
m (Removed extra blank line.)
 
(48 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{todo|Port this (In Progress)|Klint Youngmeyer|project=oe 4,oe 5,ky}}
+
{{todo|SEOKWREV;(10.29.13-22:40->MD+)(11.06.13-15:20->JG+);(1.2.14-11:40->MD+);(1.3.14-13:00->MW+);(03.04.14-16:45->BS-);(03.25.14-15:50->BS+)|Klint Youngmeyer|project=oe 4,oe 5,ky,md,bs,SEOKWREV}}
  
<!--see http://wiki.emacinc.com/doku.php?id=linux:eclipse:example
+
{{#seo:
 
+
|title=Using the EMAC OE SDK Projects with Eclipse
SIE
+
|titlemode=append
Empty. Relevant old wiki page: New EMAC OE SDK Project Using Eclipse http://wiki.emacinc.com/doku.php?id=linux:eclipse:newproject-->
+
|keywords=EMAC OE SDK,Projects,Eclipse,EMAC SDK Example,C and Makefile
 
+
|description=Using the EMAC OE SDK projects with Eclipse.
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_EMAC_Eclipse|First Time Starting EMAC Eclipse]].This guide uses the ''hello'' EMAC OE SDK example project. It consists of a C file and ''Makefile''.  
+
}}
 +
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_EMAC_Eclipse|First Time Starting Eclipse]].  
  
 
==== Tools Required ====
 
==== Tools Required ====
 
* GNU ''make''
 
* GNU ''make''
 
* EMAC OE SDK
 
* EMAC OE SDK
* ''wput''
+
* wput
 
 
<br />{{Fmbox | type =  | text ='''NOTE''' The required tools are preinstalled on the LDC.}}
 
 
 
  
 
== EMAC SDK Example: Compile and Run the hello Project ==
 
== EMAC SDK Example: Compile and Run the hello Project ==
 
=== Setup ===
 
=== Setup ===
# Modify ''global.properties'' according to the [[Remote_System_Explorer_Configuration_for_EMAC_Eclipse|SDK Remote Upload Setup]] to provide ''make'' with the correct user, password, and IP address for the ''upload'' target.
+
 
 +
# Make sure the system is [[Configuring_EMAC_OE_4.0_SDK | configured]] for the correct target machine and that the IP and user/password are set.
 
# Create a [[Using_the_Eclipse_Terminal_View|remote terminal connection]]. This is necessary to use the Remote System Explorer's SSH Terminal feature in the following procedure.
 
# Create a [[Using_the_Eclipse_Terminal_View|remote terminal connection]]. This is necessary to use the Remote System Explorer's SSH Terminal feature in the following procedure.
=== Building the Project ===
+
# Launch Eclipse and [[Importing_the_EMAC_OE_SDK_Projects_with_Eclipse | Import ]] the SDK projects if not already done.
This procedure provides an overview of how to compile and run C applications for EMAC products in Eclipse. It assumes familiarity with the C programming language and is not intended as a general guide on learning to program.
 
# Click ''Window → Open Perspective → Other...'' To bring up a dialog window with a list of Perspectives to choose from.
 
# Choose ''C/C++'' and click ''Ok''.<ref name="Note 1">See Note 1</ref>
 
 
 
==== Building With the Eclipse Managed Build System ====
 
To build using Eclipse's managed build system, a project needs to be created from the Makefile-based project.  To do this, perform the following steps:
 
# Select ''File->New->Makefile Project with Existing Code''
 
# In the window that appears (as shown below), click the ''Browse...'' button.<br /><br />
 
 
 
[[File:Import existing code.png|Import Existing Code]]<br />
 
<br />
 
==== Choosing the Project ====
 
# Navigate to the location of the project.  By default, this is under your home directory in <code>EMAC-OE-arm-linux-gnueabi-SDK_4.0/projects/hello</code>
 
# The files listed in the directory will be greyed out, but this is to be expected: Eclipse is just looking for the root directory of the project you are importing.  Click the ''OK'' button.
 
#Your ''Import'' window should now look similar to this:<br /><br />
 
[[File:Import project hello.png|Import "Hello" Project]]<br /><br />
 
Click the ''Finish'' button.You should now see the following in your ''Project Explorer'':<br /><br />
 
[[File:Proj expl after hello import.png|Project Explorer after importing "Hello" project.]]<br /><br />
 
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 <code>hello.c</code> file to open it.  '''''Note''': This step is not necessary for building the project.''  Notice the arrowhead which appeared next to <code>hello.c</code>.  This indicates that the file is now open.<br /><br />
 
 
 
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 the screenshot below:<br /><br />
 
 
 
[[File:Eclipse hello project built.png|Eclipse window after building the "Hello" example project.]]<br /><br />
 
 
 
 
 
If there are any build errors, they will be shown in the ''Console'' and/or ''Problems'' tabs on the bottom.<br /><br />
 
 
 
== EMAC SDK with Qt Example: Compile and Run the <code>textedit</code> Project ==
 
=== Importing the Project ===
 
 
 
This procedure provides an overview of how to compile and run Qt C++ applications for EMAC products in Eclipse. It assumes familiarity with the C++ programming language and is not intended as a general guide on learning to program, learning C++, or learning Qt.
 
 
 
#Click ''Window → Open Perspective → Other...'' To bring up a dialog window with a list of Perspectives to choose from.
 
#Choose ''Qt C++'' and click ''Ok''.
 
 
 
==== Building With the Eclipse Managed Build System ====
 
  
To build using Eclipse's managed build system, the project needs to be imported using its ''.pro'' project file.  To do this, perform the following steps:
+
=== Procedure ===
  
{{Fmbox | type = | text =**NOTE**: The first project which must be imported and built is the ''shared'' projectThe rest of the examples in the ''projects/qt_demos'' directory depend on the ''shared'' project. Once it has been built, it is safe to close the project and/or remove the project from Eclipse (just be sure to not remove it from disk).}}<br />
+
This guide will compile and upload one of the SDK example projects to a board using ''make'' targets. Also, the Eclipse Remote Terminal will be used to run the program.
 +
<cl>
 +
1. Open C/C++ perspective
 +
  * Click ''Window → Open Perspective → Other...'' To bring up a dialog window with a list of Perspectives to choose from.
 +
* Choose ''C/C++'' and click ''Ok''.
 +
* Open Make Target View
 +
* Click ''Window → Show View → Other ...'' To bring up a dialog window with a list of Views to choose from.
 +
  * Choose ''Make → Make Target''
 +
* Expand ''projects → hello'' in the ''Make Target'' view.
 +
* Double-click the ''all'' <code>make</code> Target to compile the project. See Figure 1 below.
  
# In the ''Project Explorer'' treeview control on the left side of the screen, make sure nothing is selected (click in a blank area, if necessary), put the mouse cursor in a blank area and right click.  From the context menu which appears, select, ''Import...''  <br /><br />[[File:Eclipse import project context selected.png|Importing a project into Eclipse]]<br /><br />
+
[[File:Make_all_nodeco1.png|500px|thumb|left| Figure 1. Make all]]
# In the window that appears (as shown below), make sure ''Qt Project'' is selected from the ''Qt'' entry in the treeview. <br /><br />[[File:Eclipse_import_project_step1.png|Selecting Qt Project as the project type]] <br /><br />
 
# Click ''Next >'', then click the ''Browse...'' button and navigate to the <code>projects/qt_demos/textedit</code> directory underneath the install location of your EMAC OE Qt SDK. <br /><br />[[File:Eclipse_import_project_step2.png|Choosing the Qt project to import]] <br /><br />
 
# Highlight the ''.pro'' file, as shown above, and click ''OK''.
 
#Click ''Finish''. <br /><br />
 
  
=== Building the Project ===
+
<br clear=all>
  
You should now see the following in your ''Project Explorer'':<br />
+
The ''all'' <code>make</code> target tells <code>make</code> to run the compiler to compile all of the source files listed in the <code>CFILES</code> variable in the <code>Makefile</code>. <code>make</code> will check the modification times of these *.c files against that of the currently existing executable (if there is one) to see if they have been modified since the last time the executable was compiled. If they have, make reruns the toolchain commands necessary to produce a new executableFor a more in-depth explanation see the [http://www.gnu.org/software/make/manual/make.html | GNU `make' Manual]
<br />[[File:Eclipse_textedit_project_selected.png|Project Explorer after importing <code>textedit</code> project.]]<br />
+
* Double click the ''upload'' <code>make</code> target to upload the program to the target machine. See Figure 2 below.
<br />The arrowhead to the left of ''textedit'' indicates that the ''textedit'' project is open.  Click on the arrowhead to see the files in the project.  Double click on the <code>textedit.cpp</code> file to open it.  '''''Note''': This step is not necessary for building the project.''  Notice the arrowhead which appears next to <code>textedit.cpp</code>.  This can be used to see a list of classes and functions available within this source file.<br />
+
[[File:make_upload_nodeco1.png|500px|thumb|left|Figure 2. Make upload]]
<br />To build the project, ensure the project is highlighted in the ''Project Explorer'' treeview in the left pane, then select ''Project→Run qmake''. Now, select ''Project→Build Project''The project will now build, and your window should appear similar to the screenshot below:<br />
 
<br />[[File:Eclipse_qt_build_textedit_finished.png|Eclipse window after building the <code>textedit</code> example project.]]<br />
 
<br />If there are any build errors, they will be shown in the ''Console'' and/or ''Problems'' tabs on the bottom.<br />
 
<br />
 
  
=== Building With Make Targets ===
+
<br clear=all>
  
# Select the ''Make Targets'' View.
+
The ''upload'' <code>make</code>  target tells <code>make</code> to use the <code>wput</code> command to send the binary to the target machine using the variables stored in the <code>global.properties</code> file.
# Expand ''EMAC-OE-arm-linux-gnueabi-SDK_4.0 → projects → hello''.<ref name="Note 2">See Note 2</ref>
+
   
# Cross-compile the program:<br >Click on the project you're building in the left pane to '''ensure it is highlighted in blue'''. The result is shown in Figure 1 below.  Now click on ''Project→Build Project''.<br />[[File:Eclipse_make_hello.png|Figure 1]]<br />'''Figure 1: Build Project'''<br /> The project to be built '''must''' be hilighted in the left pane, as shown in Figure 1, before you click ''Project→Build Project'' to compile the hello example project (this is true any time you build a project).  ''Build Project'' will perform an incremental build of the currently selected project.  Choosing ''Project→Clean...'' before choosing ''Project→Build Project'' will perform a full rebuild of the project.  The method used to determine what to build during an incremental build can be found here: [http://www.gnu.org/software/make/manual/make.html GNU 'make' Manual].
+
* Now [[Remote_System_Explorer_Shell_and_Terminal_Setup|Connect]] to the target machine.
 +
* Run the program as shown below using the remote terminal created in the[[Remote_System_Explorer_Shell_and_Terminal_Setup | Remote Terminal Setup Guide]].
  
<br />{{Fmbox | type =  | text ='''Note 1''': If you have the Qt SDK, you will need to choose ''Qt C++'' instead to work with Qt projects.  For this first example, though, the ''C/C++'' perspective is the correct one to use with the example program demonstrated here.}}
+
[[File:Chmod_run_phello1.png|400px|thumb|left|Figure 3. Remote Terminal]]
  
{{Fmbox | type = | text ='''Note 2''': If you are unable to expand ''EMAC-OE-arm-linux-gnueabi-SDK_4.0'', right-click on it and choose, ''Open Project''. This should then cause an arrowhead to appear to the left of ''EMAC-OE-arm-linux-gnueabi-SDK_4.0''.  Click the arrowhead to expand it. This feature allows you to only keep the project you're currently working on open so that metadata for all your projects is not allocated in RAM.<br /><br /> '''To close a project''' you're not actively working on, right click on the project and click, ''Close Project''. More conveniently, to close all projects other than the one you are currently working on, right-click on your current project, and click, ''Close Unrelated Projects''.}}
+
<br clear=all>
 +
</cl>
 +
The following is a brief description of each command seen in the SSH Terminal window above:
 +
* <code>cd /tmp</code>: Change the current working directory to <code>/tmp/</code>.
 +
* <code>ls -l</code>: List the current working directory's contents with file permissions shown. Notice that root does not have execute permissions for the file <code>hello</code>.
 +
* <code>chmod u+x hello</code>: Give executable permissions to the owner of the <code>hello</code> file. Note that this assumes that the same user is used to log in through the SSH Terminal as was specified in <code>global.properties</code> according to Step 1 of the Setup for this guide; in this example, the user is <code>root</code>.
 +
* <code>ls -l</code>: List the current working directory's contents with file permissions shown to be sure that root now has execute permission. The new <code>x</code> indicates that <code>root</code> does now have execute permissions.
 +
* <code>./hello</code>: Execute the binary. The output shown is a simple message printed to the screen, "Hello EMAC OE!".
  
=== Uploading the Project to the Target Machine ===
+
==Example C and Makefile==
  
 +
See [[Using_EMAC_OE_SDK_Example_Projects#Example_C_File | example files ]] for more information about the files used in this procedure.
  
 +
== Next Steps ==
  
 +
The next step is to create a new  [[Creating_New_Projects_with_Eclipse|Makefile-based Eclipse project.]]
  
<references />
+
<!--[[Category:Eclipse]]-->

Latest revision as of 16:29, 18 November 2014

TODO: {{#todo:SEOKWREV;(10.29.13-22:40->MD+)(11.06.13-15:20->JG+);(1.2.14-11:40->MD+);(1.3.14-13:00->MW+);(03.04.14-16:45->BS-);(03.25.14-15:50->BS+)|Klint Youngmeyer|oe 4,oe 5,ky,md,bs,SEOKWREV}}

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. Make sure the system is configured for the correct target machine and that the IP and user/password are set.
  2. Create a remote terminal connection. This is necessary to use the Remote System Explorer's SSH Terminal feature in the following procedure.
  3. Launch Eclipse and Import the SDK projects if not already done.

Procedure

This guide will compile and upload one of the SDK example projects to a board using make targets. Also, the Eclipse Remote Terminal will be used to run the program.

  1. Open C/C++ perspective

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

    • Choose C/C++ and click Ok.

  2. Open Make Target View

    • Click Window → Show View → Other ... To bring up a dialog window with a list of Views to choose from.

    • Choose Make → Make Target

  3. Expand projects → hello in the Make Target view.

  4. Double-click the all make Target to compile the project. See Figure 1 below.

    Figure 1. Make all


    The all make target tells make to run the compiler to compile all of the source files listed in the CFILES variable in the Makefile. make will check the modification times of these *.c files against that of the currently existing executable (if there is one) to see if they have been modified since the last time the executable was compiled. If they have, make reruns the toolchain commands necessary to produce a new executable. For a more in-depth explanation see the | GNU `make' Manual

  5. Double click the upload make target to upload the program to the target machine. See Figure 2 below.

    Figure 2. Make upload


    The upload make target tells make to use the wput command to send the binary to the target machine using the variables stored in the global.properties file.

  6. Now Connect to the target machine.

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

    Figure 3. Remote Terminal


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!".

Example C and Makefile

See example files for more information about the files used in this procedure.

Next Steps

The next step is to create a new Makefile-based Eclipse project.