Difference between revisions of "Creating New Projects with Eclipse"
Kyoungmeyer (talk | contribs) (→Creating a New SDK QT Project) |
|||
(46 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | {{todo|Port this and finish it. (11. | + | {{todo|SEOKWREV <strike>Port this and finish it.</strike> (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|project=oe 4,SEOKWREV,ky,mg,bs}} |
− | The purpose of this guide is to demonstrate how to create | + | {{#seo: |
+ | |title=Creating New Projects with Eclipse | ||
+ | |titlemode=append | ||
+ | |keywords=Eclipse,Creating Projects,SDK C Project,Creating SDK QT Project,QT GUI Project | ||
+ | |description=Creating new projects with Eclipse. | ||
+ | }} | ||
+ | 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 [[ Installing_EMAC_OE_4.0_SDK | installed ]] and [[Configuring_EMAC_OE_4.0_SDK | configured ]]. | ||
<br clear=all> | <br clear=all> | ||
Line 7: | Line 13: | ||
==Required Tools== | ==Required Tools== | ||
* GNU ''Make'' | * GNU ''Make'' | ||
− | * [[ | + | * [[ Eclipse_Introduction | Eclipse 3.6 ]] |
* [[ EMAC_OE_SDK_Introduction | EMAC OE SDK ]] | * [[ EMAC_OE_SDK_Introduction | EMAC OE SDK ]] | ||
Line 15: | Line 21: | ||
1. Start Eclipse. | 1. 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. | + | The recommended location is /path/to/sdk/projects. This will allow the user to easily leverage the use of the SDK. See the section below on [[Creating_New_Projects_with_Eclipse#Alternate_Project_Locations | alternate project locations]].}} |
+ | <br clear=all> | ||
− | [[File:Select_workspace.png| | + | [[File:Select_workspace.png|600px|thumb|left|Figure 1: Select Eclipse Workspace]] |
<br clear=all> | <br clear=all> | ||
− | * From the Eclipse menubar, select File->New->Project | + | * From the Eclipse menubar, select ''File->New->Project'' |
− | * Under C/C++, select C Project then | + | * Under C/C++, select ''C Project'' then ''Next >'' |
[[File:Eclipse_new_C_project.png|600px|thumb|left|Figure 2. Open C Project]] | [[File:Eclipse_new_C_project.png|600px|thumb|left|Figure 2. Open C Project]] | ||
Line 29: | Line 36: | ||
* Enter “hello” in the Project name: field. | * Enter “hello” in the Project name: field. | ||
− | * Scroll down and choose Makefile Project -> Empty Project in the Project | + | * Scroll down and choose ''Makefile Project -> Empty Project'' in the Project Type: list. |
− | * 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 52: | Line 59: | ||
1. Open the C/C++ Perspective if it is not open already. | 1. Open the C/C++ Perspective if it is not open already. | ||
i. From the Eclipse menubar, select ''Window -> Open Perspective -> Other...'' | i. From the Eclipse menubar, select ''Window -> Open Perspective -> Other...'' | ||
− | * Select C/C++ and click OK | + | * Select ''C/C++'' and click ''OK'' |
* Create a new C file using the Eclipse New Source Wizard. | * Create a new C file using the Eclipse New Source Wizard. | ||
i. From the Eclipse menubar, select ''File-> New-> Source File''. | i. From the Eclipse menubar, select ''File-> New-> Source File''. | ||
Line 63: | Line 70: | ||
<br clear=all> | <br clear=all> | ||
− | * If the new C file did not open automatically, open it by double clicking hello.c | + | * If the new C file did not open automatically, open it by double clicking hello.c in the left pane |
− | * Copy the code from | + | * Copy the code from [[Creating_a_New_EMAC_OE_SDK_Project#Write_the_C_Code | Listing 1 in the 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 6 for how Eclipse should look. | * Save the file by selecting ''File->Save'' from the Eclipse menubar. See Figure 6 for how Eclipse should look. | ||
Line 74: | Line 81: | ||
==Make file Setup== | ==Make file Setup== | ||
− | Make files are used by Eclipse | + | 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=== | ===Generate Eclipse Make Targets=== | ||
− | The following will demonstrate how to add the ''all'', ''clean'' and ''upload'' targets for ''make'' | + | The following will demonstrate how to add the ''all'', ''clean'' and ''upload'' targets for ''make''. |
<cl> | <cl> | ||
Line 91: | Line 98: | ||
<br clear=all> | <br clear=all> | ||
− | * Create the make targets ''all, clean'' and ''upload'' as in | + | * Create the make targets ''all, clean'' and ''upload'' as in Figures 8,9 and 10. |
<gallery widths=300px heights=400px mode="traditional"> | <gallery widths=300px heights=400px mode="traditional"> | ||
− | File:Make_new_all.png|Figure 8: Make | + | File:Make_new_all.png|Figure 8: Make new ''All'' target |
− | File:Make_new_clean.png|Figure 9: Make | + | File:Make_new_clean.png|Figure 9: Make new ''Clean'' target |
− | File:Make_new_upload.png|Figure 10: Make | + | File:Make_new_upload.png|Figure 10: Make new ''Upload'' target |
</gallery> | </gallery> | ||
</cl> | </cl> | ||
Line 102: | Line 109: | ||
===Modify the Makefile=== | ===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 | + | 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=== | ===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 | + | 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. |
:[[File:Eclipse hello project built.png|600px|thumb|left|Figure 11: Eclipse Workspace]] | :[[File:Eclipse hello project built.png|600px|thumb|left|Figure 11: Eclipse Workspace]] | ||
Line 111: | Line 118: | ||
<br clear=all> | <br clear=all> | ||
− | + | 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== | ==Creating a New SDK QT Project== | ||
Line 120: | Line 126: | ||
<cl> | <cl> | ||
1. Start Eclipse. | 1. 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 12: New Qt Project ]] | [[File:New_qt_project.png|600px|thumb|left|Figure 12: New Qt Project ]] | ||
Line 127: | Line 133: | ||
<br clear=all> | <br clear=all> | ||
− | * Enter myproject in the Project Name: field and click Finish. | + | * Enter myproject in the ''Project Name'': field and click ''Finish''. |
{{mbox | type=information | text = Make sure that the Location is set to the /path/to/sdk/projects folder as noted above.}}<br clear=all> | {{mbox | type=information | text = Make sure that the Location is set to the /path/to/sdk/projects folder as noted above.}}<br clear=all> | ||
Line 135: | Line 141: | ||
<br clear=all> | <br clear=all> | ||
− | * 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 14: New Qt Project ]] | [[File:New_qt_project_pg2.png|600px|thumb|left|Figure 14: New Qt Project ]] | ||
Line 141: | Line 147: | ||
<br clear=all> | <br clear=all> | ||
− | * 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 15: New Qt Project ]] | [[File:New_qt_gui_project_pg3.png|600px|thumb|left|Figure 15: New Qt Project ]] | ||
Line 149: | Line 155: | ||
</cl> | </cl> | ||
− | The project is now set up and ready to begin coding an application. For more information on creating Qt applications see [http://qt-project.org/doc/qt-4.8/gettingstartedqt.html Getting Started Programming with Qt] on the Qt website. | + | The project is now set up and ready to begin coding an application. For more information on creating ''Qt'' applications see [http://qt-project.org/doc/qt-4.8/gettingstartedqt.html Getting Started Programming with Qt] on the Qt website. |
==QT GUI Project== | ==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. | + | The Eclipse IDE contains a graphical editor for creating GUI applications. The following will show the steps for using the ''Qt Designer Editor''. |
<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 | + | * Double click on the myproject.ui file in the ''Project Explorer'' pane. This will open the ''Qt Designer Editor'' window. See Figure 16. |
[[File:Eclipse_qt_designer_new_ui.png|600px|thumb|left|Figure 16: Eclipse Qt Designer Editor window ]] | [[File:Eclipse_qt_designer_new_ui.png|600px|thumb|left|Figure 16: Eclipse Qt Designer Editor window ]] | ||
Line 163: | Line 169: | ||
<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 | ||
Line 171: | Line 177: | ||
<br clear=all> | <br clear=all> | ||
− | 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 | + | * Under ''QT'', select ''Qt C++ Widget Box'' then click ''OK'' |
[[File:Eclipse_qt_widget_box.png|600px|thumb|left|Figure 18: Qt Designer Geometry Properties ]] | [[File:Eclipse_qt_widget_box.png|600px|thumb|left|Figure 18: Qt Designer Geometry Properties ]] | ||
Line 183: | Line 189: | ||
==Alternate Project Locations== | ==Alternate Project Locations== | ||
− | If the project is created outside of the /path/to/sdk/projects directory, the paths present in the | + | 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. |
<cl> | <cl> | ||
− | 1. Copy the correct global.properties file from the SDK/projects directory to the current project directory | + | 1. Copy the correct ''global.properties'' file from the ''SDK/projects'' directory to the current project directory |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 193: | Line 199: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | * Modify the include line at the top of the make file to refer to the new global.properties file | + | * Modify the ''include'' line at the top of the make file to refer to the new ''global.properties'' file |
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
include global.properties | include global.properties | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | * Change the value of <code>SDKBASE</code> in global.properties to point to the location of the SDK installation. | + | * Change the value of <code>SDKBASE</code> in ''global.properties'' to point to the location of the SDK installation. |
</cl> | </cl> | ||
− | + | <!--Old pages: | |
− | Old pages: | ||
http://wiki.emacinc.com/doku.php?id=linux:eclipse:newproject | http://wiki.emacinc.com/doku.php?id=linux:eclipse:newproject | ||
Line 210: | Line 215: | ||
http://wiki.emacinc.com/doku.php?id=linux:eclipse:example | http://wiki.emacinc.com/doku.php?id=linux:eclipse:example | ||
− | http://wiki.emacinc.com/doku.php?id=linux:ldc:eclipse#creating_eclipse_make_targets | + | http://wiki.emacinc.com/doku.php?id=linux:ldc:eclipse#creating_eclipse_make_targets--> |
==See Also== | ==See Also== | ||
− | [http://www.eclipse.org/documentation/ '''Eclipse Documentation'''] | + | *[http://www.eclipse.org/documentation/ '''Eclipse Documentation'''] |
− | + | *[http://qt-project.org/doc/ '''QT Documentation'''] | |
− | [http://qt-project.org/doc/ '''QT Documentation'''] | ||
− | [[Category: | + | <!--[[Category:Eclipse]]--> |
Latest revision as of 15:04, 25 March 2014
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 .
Contents
Required Tools
- GNU Make
- Eclipse 3.6
- EMAC OE SDK
Creating a New SDK C Project
-
Start Eclipse.
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. See the section below on alternate project locations.
-
From the Eclipse menubar, select File->New->Project
-
Under C/C++, select C Project then Next >
-
Enter “hello” in the Project name: field.
-
Scroll down and choose Makefile Project -> Empty Project in the Project Type: list.
-
Ensure that – Other Toolchain – is selected in the Toolchains: list.
-
Click the Finish button.
-
Select Yes to open the C/C++ perspective if prompted.
-
The workbench should look similar to Figure 4 below.
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.
-
Open the C/C++ Perspective if it is not open already.
-
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.
-
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 in the left pane
-
Copy the code from Listing 1 in the 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 6 for how Eclipse should look.
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.
-
Click on the Make Target view tab in the right hand pane.
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...
-
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.
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.
-
Start Eclipse.
-
From the Eclipse menubar, select File->New->Project
-
Under Qt, select Qt Gui Project or Qt Console Project then click Next
-
Enter myproject in the Project Name: field and click Finish.
Make sure that the Location is set to the /path/to/sdk/projects folder as noted above.
-
Accept the default file names for the project and click Next
-
Select any additional Qt modules that are required for the project, then click Finish
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.
-
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 16.
-
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
The QT C++ Widget Box allows the user to drag and drop components (buttons, textboxes, labels...) onto the editor.
-
-
To show the editor:
-
On the Eclipse menubar click Window->Show View->Other...
-
Under QT, select Qt C++ Widget Box then click OK
-
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.
-
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
-
Modify the include line at the top of the make file to refer to the new global.properties file
include global.properties
-
Change the value of
SDKBASE
in global.properties to point to the location of the SDK installation.
See Also