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.)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{todo|Completed; (10.29.13-22:40->MD+)(11.06.13-15:20->JG+)|Klint Youngmeyer|project=oe 4,oe 5,ky,Complete, md}}
+
{{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 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 Eclipse]].  
  
Line 14: Line 16:
 
== 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 [[Eclipse_Remote_System_Explorer|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.
=== Create a new Makefile-based project ===
+
# Launch Eclipse and [[Importing_the_EMAC_OE_SDK_Projects_with_Eclipse | Import ]] the SDK projects if not already done.
<cl>
 
1. 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''.
 
* Select ''File→New→Makefile Project with Existing Code''
 
* In the window that appears, click the ''Browse...'' button.
 
  
[[File:Import existing code.png|400px|thumb|left]]
+
=== Procedure ===
  
<br clear=all>
+
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>
* Navigate to the location of the project. By default this is under the home directory in <code>~/EMAC-OE-arm-linux-gnueabi-SDK_4.0/projects/hello</code>
+
1. Open C/C++ perspective
* Click the ''OK'' button.
+
* 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''.
[[File:Import project hello.png|400px|thumb|left]]
+
* Open Make Target View
 
+
* Click ''Window → Show View → Other ...'' To bring up a dialog window with a list of Views to choose from.
<br clear=all>
+
* Choose ''Make → Make Target''
 
+
* Expand ''projects → hello'' in the ''Make Target'' view.
* Click the ''Finish'' button.
+
* Double-click the ''all'' <code>make</code> Target to compile the project. See Figure 1 below.
 
 
[[File:Proj expl after hello import.png|400px|thumb|left]]
 
 
 
<br clear=all>
 
 
 
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.
 
 
 
* 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:
 
  
[[File:Eclipse hello project built.png|600px|thumb|left]]
+
[[File:Make_all_nodeco1.png|500px|thumb|left| Figure 1. Make all]]
  
 
<br clear=all>
 
<br clear=all>
  
Any build errors will be shown in the ''Console'' and/or ''Problems'' tabs on the bottom.
+
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 executable.  For a more in-depth explanation see the [http://www.gnu.org/software/make/manual/make.html | GNU `make' Manual]
</cl>
+
* Double click the ''upload'' <code>make</code> target to upload the program to the target machine. See Figure 2 below.
 
+
[[File:make_upload_nodeco1.png|500px|thumb|left|Figure 2. Make upload]]
=== Uploading the Project to the Target Machine ===
 
 
 
<cl>
 
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''
 
* Right click on the ''Make Target'' view tab and choose ''New...''
 
 
 
* Type ''upload'' as the Target name and click ''OK''
 
 
 
[[File:Create_make_target.png|400px|thumb|left]]
 
  
 
<br clear=all>
 
<br clear=all>
  
* To upload the executable to the target machine right click on the ''upload'' target in the ''Make Targets'' window and select ''Build Target''
+
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.
 
 
The binary executable should be uploaded to the target machine.  If there is an error, check to make sure the <code>wput</code> command installed, and that it can be called from within the Eclipse IDE
 
 
   
 
   
 
* Now [[Remote_System_Explorer_Shell_and_Terminal_Setup|Connect]] to the target machine.
 
* 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 Terminal Setup Guide.
+
* Run the program as shown below using the remote terminal created in the[[Remote_System_Explorer_Shell_and_Terminal_Setup | Remote Terminal Setup Guide]].
  
[[File:Chmod_run_phello1.png|400px|thumb|left]]
+
[[File:Chmod_run_phello1.png|400px|thumb|left|Figure 3. Remote Terminal]]
  
 
<br clear=all>
 
<br clear=all>
Line 77: Line 56:
 
* <code>cd /tmp</code>: Change the current working directory to <code>/tmp/</code>.
 
* <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>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 'global.properties'' according to Step 1 of the Setup for this guide--in this example, the user is <code>root</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>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!".
 
* <code>./hello</code>: 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 <code>textedit</code> Project ==
+
==Example C and Makefile==
=== Importing the Project ===
 
  
This procedure provides an overview of how to compile and run Qt C++ applications in Eclipse.
+
See [[Using_EMAC_OE_SDK_Example_Projects#Example_C_File | example files ]] for more information about the files used in this procedure.
<cl>
 
1. 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''.
 
* Select ''File→Import...''
 
* Expand Qt and select Qt Project
 
 
 
[[File:Eclipse_import_project_step1.png|500px|thumb|left]]
 
 
 
<br clear=all>
 
 
 
* Click ''Next >'', then click ''Browse...''
 
* Navigate to the <code>projects/qt_demos/textedit</code> directory underneath the install location of the EMAC OE SDK.
 
* Highlight ''textedit.pro'' then click ''OK''.
 
* Click ''Finish''.
 
 
 
[[File:Eclipse_import_project_step2.png|500px|thumb|left]]
 
 
 
<br clear=all>
 
</cl>
 
===Building the Project===
 
 
 
The ''Project Explorer'' should now show the ''textedit'' project.
 
 
 
:: [[File:Eclipse_textedit_project_selected.png|600px|thumb|left]]
 
 
 
<br clear=all>
 
 
 
The arrowhead to the left of ''textedit'' indicates that the ''textedit'' project is open.
 
<cl>
 
1. Click on the arrowhead to see the files in the project.
 
* Double click on the <code>textedit.cpp</code> 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.
 
 
 
* To build the project, ensure the project is highlighted in the ''Project Explorer'' treeview in the left pane.
 
* Select ''Project→Run qmake''
 
* Now, select ''Project→Build Project''.  The project will now build, and your window should appear similar to the screenshot below:
 
 
 
[[File:Eclipse_qt_build_textedit_finished.png|x400px|thumb|left]]
 
 
 
<br clear=all>
 
 
 
If there are any build errors they will be shown in the ''Console'' and/or ''Problems'' tabs on the bottom.
 
</cl>
 
  
 
== Next Steps ==
 
== Next Steps ==
  
The next step is to create a new  [[Creating_New_Projects_with_Eclipse|New Project Guide | Makefile-based Eclipse project.]]
+
The next step is to create a new  [[Creating_New_Projects_with_Eclipse|Makefile-based Eclipse project.]]
  
[[Category:Eclipse]]
+
<!--[[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.