Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1 | <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
| 2 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" |
| 3 | [<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] > |
| 4 | |
| 5 | <chapter id='sdk-working-projects'> |
| 6 | |
| 7 | <title>Using the SDK Toolchain Directly</title> |
| 8 | |
| 9 | <para> |
| 10 | You can use the SDK toolchain directly with Makefile, |
| 11 | Autotools, and <trademark class='trade'>Eclipse</trademark> based |
| 12 | projects. |
| 13 | This chapter covers information specific to each of these types of |
| 14 | projects. |
| 15 | </para> |
| 16 | |
| 17 | <section id='autotools-based-projects'> |
| 18 | <title>Autotools-Based Projects</title> |
| 19 | |
| 20 | <para> |
| 21 | Once you have a suitable cross-toolchain installed, it is very easy |
| 22 | to develop a project outside of the OpenEmbedded build system. |
| 23 | This section presents a simple "Helloworld" example that shows how |
| 24 | to set up, compile, and run the project. |
| 25 | </para> |
| 26 | |
| 27 | <section id='creating-and-running-a-project-based-on-gnu-autotools'> |
| 28 | <title>Creating and Running a Project Based on GNU Autotools</title> |
| 29 | |
| 30 | <para> |
| 31 | Follow these steps to create a simple Autotools-based project: |
| 32 | <orderedlist> |
| 33 | <listitem><para> |
| 34 | <emphasis>Create your directory:</emphasis> |
| 35 | Create a clean directory for your project and then make |
| 36 | that directory your working location: |
| 37 | <literallayout class='monospaced'> |
| 38 | $ mkdir $HOME/helloworld |
| 39 | $ cd $HOME/helloworld |
| 40 | </literallayout> |
| 41 | </para></listitem> |
| 42 | <listitem><para> |
| 43 | <emphasis>Populate the directory:</emphasis> |
| 44 | Create <filename>hello.c</filename>, |
| 45 | <filename>Makefile.am</filename>, |
| 46 | and <filename>configure.ac</filename> files as follows: |
| 47 | <itemizedlist> |
| 48 | <listitem><para> |
| 49 | For <filename>hello.c</filename>, include |
| 50 | these lines: |
| 51 | <literallayout class='monospaced'> |
| 52 | #include <stdio.h> |
| 53 | |
| 54 | main() |
| 55 | { |
| 56 | printf("Hello World!\n"); |
| 57 | } |
| 58 | </literallayout> |
| 59 | </para></listitem> |
| 60 | <listitem><para> |
| 61 | For <filename>Makefile.am</filename>, |
| 62 | include these lines: |
| 63 | <literallayout class='monospaced'> |
| 64 | bin_PROGRAMS = hello |
| 65 | hello_SOURCES = hello.c |
| 66 | </literallayout> |
| 67 | </para></listitem> |
| 68 | <listitem><para> |
| 69 | For <filename>configure.in</filename>, |
| 70 | include these lines: |
| 71 | <literallayout class='monospaced'> |
| 72 | AC_INIT(hello,0.1) |
| 73 | AM_INIT_AUTOMAKE([foreign]) |
| 74 | AC_PROG_CC |
| 75 | AC_PROG_INSTALL |
| 76 | AC_OUTPUT(Makefile) |
| 77 | </literallayout> |
| 78 | </para></listitem> |
| 79 | </itemizedlist> |
| 80 | </para></listitem> |
| 81 | <listitem><para> |
| 82 | <emphasis>Source the cross-toolchain |
| 83 | environment setup file:</emphasis> |
| 84 | As described earlier in the manual, installing the |
| 85 | cross-toolchain creates a cross-toolchain |
| 86 | environment setup script in the directory that the SDK |
| 87 | was installed. |
| 88 | Before you can use the tools to develop your project, |
| 89 | you must source this setup script. |
| 90 | The script begins with the string "environment-setup" |
| 91 | and contains the machine architecture, which is |
| 92 | followed by the string "poky-linux". |
| 93 | Here is an example that sources a script from the |
| 94 | default SDK installation directory that uses the |
| 95 | 32-bit Intel x86 Architecture and the |
| 96 | &DISTRO_NAME; Yocto Project release: |
| 97 | <literallayout class='monospaced'> |
| 98 | $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux |
| 99 | </literallayout> |
| 100 | </para></listitem> |
| 101 | <listitem><para> |
| 102 | <emphasis>Generate the local aclocal.m4 |
| 103 | files and create the configure script:</emphasis> |
| 104 | The following GNU Autotools generate the local |
| 105 | <filename>aclocal.m4</filename> files and create the |
| 106 | configure script: |
| 107 | <literallayout class='monospaced'> |
| 108 | $ aclocal |
| 109 | $ autoconf |
| 110 | </literallayout> |
| 111 | </para></listitem> |
| 112 | <listitem><para> |
| 113 | <emphasis>Generate files needed by GNU coding |
| 114 | standards:</emphasis> |
| 115 | GNU coding standards require certain files in order |
| 116 | for the project to be compliant. |
| 117 | This command creates those files: |
| 118 | <literallayout class='monospaced'> |
| 119 | $ touch NEWS README AUTHORS ChangeLog |
| 120 | </literallayout> |
| 121 | </para></listitem> |
| 122 | <listitem><para> |
| 123 | <emphasis>Generate the configure file:</emphasis> |
| 124 | This command generates the |
| 125 | <filename>configure</filename>: |
| 126 | <literallayout class='monospaced'> |
| 127 | $ automake -a |
| 128 | </literallayout> |
| 129 | </para></listitem> |
| 130 | <listitem><para> |
| 131 | <emphasis>Cross-compile the project:</emphasis> |
| 132 | This command compiles the project using the |
| 133 | cross-compiler. |
| 134 | The |
| 135 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIGURE_FLAGS'><filename>CONFIGURE_FLAGS</filename></ulink> |
| 136 | environment variable provides the minimal arguments for |
| 137 | GNU configure: |
| 138 | <literallayout class='monospaced'> |
| 139 | $ ./configure ${CONFIGURE_FLAGS} |
| 140 | </literallayout> |
| 141 | </para></listitem> |
| 142 | <listitem><para> |
| 143 | <emphasis>Make and install the project:</emphasis> |
| 144 | These two commands generate and install the project |
| 145 | into the destination directory: |
| 146 | <literallayout class='monospaced'> |
| 147 | $ make |
| 148 | $ make install DESTDIR=./tmp |
| 149 | </literallayout> |
| 150 | </para></listitem> |
| 151 | <listitem><para> |
| 152 | <emphasis>Verify the installation:</emphasis> |
| 153 | This command is a simple way to verify the installation |
| 154 | of your project. |
| 155 | Running the command prints the architecture on which |
| 156 | the binary file can run. |
| 157 | This architecture should be the same architecture that |
| 158 | the installed cross-toolchain supports. |
| 159 | <literallayout class='monospaced'> |
| 160 | $ file ./tmp/usr/local/bin/hello |
| 161 | </literallayout> |
| 162 | </para></listitem> |
| 163 | <listitem><para> |
| 164 | <emphasis>Execute your project:</emphasis> |
| 165 | To execute the project in the shell, simply enter |
| 166 | the name. |
| 167 | You could also copy the binary to the actual target |
| 168 | hardware and run the project there as well: |
| 169 | <literallayout class='monospaced'> |
| 170 | $ ./hello |
| 171 | </literallayout> |
| 172 | As expected, the project displays the "Hello World!" |
| 173 | message. |
| 174 | </para></listitem> |
| 175 | </orderedlist> |
| 176 | </para> |
| 177 | </section> |
| 178 | |
| 179 | <section id='passing-host-options'> |
| 180 | <title>Passing Host Options</title> |
| 181 | |
| 182 | <para> |
| 183 | For an Autotools-based project, you can use the cross-toolchain |
| 184 | by just passing the appropriate host option to |
| 185 | <filename>configure.sh</filename>. |
| 186 | The host option you use is derived from the name of the |
| 187 | environment setup script found in the directory in which you |
| 188 | installed the cross-toolchain. |
| 189 | For example, the host option for an ARM-based target that uses |
| 190 | the GNU EABI is <filename>armv5te-poky-linux-gnueabi</filename>. |
| 191 | You will notice that the name of the script is |
| 192 | <filename>environment-setup-armv5te-poky-linux-gnueabi</filename>. |
| 193 | Thus, the following command works to update your project and |
| 194 | rebuild it using the appropriate cross-toolchain tools: |
| 195 | <literallayout class='monospaced'> |
| 196 | $ ./configure --host=armv5te-poky-linux-gnueabi \ |
| 197 | --with-libtool-sysroot=<replaceable>sysroot_dir</replaceable> |
| 198 | </literallayout> |
| 199 | <note> |
| 200 | If the <filename>configure</filename> script results in |
| 201 | problems recognizing the |
| 202 | <filename>--with-libtool-sysroot=</filename><replaceable>sysroot-dir</replaceable> |
| 203 | option, regenerate the script to enable the support by |
| 204 | doing the following and then run the script again: |
| 205 | <literallayout class='monospaced'> |
| 206 | $ libtoolize --automake |
| 207 | $ aclocal -I ${OECORE_TARGET_SYSROOT}/usr/share/aclocal [-I <replaceable>dir_containing_your_project-specific_m4_macros</replaceable>] |
| 208 | $ autoconf |
| 209 | $ autoheader |
| 210 | $ automake -a |
| 211 | </literallayout> |
| 212 | </note> |
| 213 | </para> |
| 214 | </section> |
| 215 | </section> |
| 216 | |
| 217 | <section id='makefile-based-projects'> |
| 218 | <title>Makefile-Based Projects</title> |
| 219 | |
| 220 | <para> |
| 221 | For Makefile-based projects, the cross-toolchain environment |
| 222 | variables established by running the cross-toolchain environment |
| 223 | setup script are subject to general <filename>make</filename> |
| 224 | rules. |
| 225 | </para> |
| 226 | |
| 227 | <para> |
| 228 | To illustrate this, consider the following four cross-toolchain |
| 229 | environment variables: |
| 230 | <literallayout class='monospaced'> |
| 231 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'>CC</ulink>=i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/&DISTRO;/sysroots/i586-poky-linux |
| 232 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LD'>LD</ulink>=i586-poky-linux-ld --sysroot=/opt/poky/&DISTRO;/sysroots/i586-poky-linux |
| 233 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink>=-O2 -pipe -g -feliminate-unused-debug-types |
| 234 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CXXFLAGS'>CXXFLAGS</ulink>=-O2 -pipe -g -feliminate-unused-debug-types |
| 235 | </literallayout> |
| 236 | Now, consider the following three cases: |
| 237 | <itemizedlist> |
| 238 | <listitem><para> |
| 239 | <emphasis>Case 1 - No Variables Set in the |
| 240 | <filename>Makefile</filename>:</emphasis> |
| 241 | Because these variables are not specifically set in the |
| 242 | <filename>Makefile</filename>, the variables retain their |
| 243 | values based on the environment. |
| 244 | </para></listitem> |
| 245 | <listitem><para> |
| 246 | <emphasis>Case 2 - Variables Set in the |
| 247 | <filename>Makefile</filename>:</emphasis> |
| 248 | Specifically setting variables in the |
| 249 | <filename>Makefile</filename> during the build results in |
| 250 | the environment settings of the variables being |
| 251 | overwritten. |
| 252 | </para></listitem> |
| 253 | <listitem><para> |
| 254 | <emphasis>Case 3 - Variables Set when the |
| 255 | <filename>Makefile</filename> is Executed from the |
| 256 | Command Line:</emphasis> |
| 257 | Executing the <filename>Makefile</filename> from the |
| 258 | command-line results in the variables being overwritten |
| 259 | with command-line content regardless of what is being set |
| 260 | in the <filename>Makefile</filename>. |
| 261 | In this case, environment variables are not considered |
| 262 | unless you use the "-e" flag during the build: |
| 263 | <literallayout class='monospaced'> |
| 264 | $ make -e <replaceable>file</replaceable> |
| 265 | </literallayout> |
| 266 | If you use this flag, then the environment values of the |
| 267 | variables override any variables specifically set in the |
| 268 | <filename>Makefile</filename>. |
| 269 | </para></listitem> |
| 270 | </itemizedlist> |
| 271 | <note> |
| 272 | For the list of variables set up by the cross-toolchain |
| 273 | environment setup script, see the |
| 274 | "<link linkend='sdk-running-the-sdk-environment-setup-script'>Running the SDK Environment Setup Script</link>" |
| 275 | section. |
| 276 | </note> |
| 277 | </para> |
| 278 | </section> |
| 279 | |
| 280 | <section id='sdk-developing-applications-using-eclipse'> |
| 281 | <title>Developing Applications Using <trademark class='trade'>Eclipse</trademark></title> |
| 282 | |
| 283 | <para> |
| 284 | If you are familiar with the popular Eclipse IDE, you can use an |
| 285 | Eclipse Yocto Plug-in to allow you to develop, deploy, and test your |
| 286 | application all from within Eclipse. |
| 287 | This section describes general workflow using the SDK and Eclipse |
| 288 | and how to configure and set up Eclipse. |
| 289 | </para> |
| 290 | |
| 291 | <section id='workflow-using-eclipse'> |
| 292 | <title>Workflow Using <trademark class='trade'>Eclipse</trademark></title> |
| 293 | |
| 294 | <para> |
| 295 | The following figure and supporting list summarize the |
| 296 | application development general workflow that employs both the |
| 297 | SDK Eclipse. |
| 298 | </para> |
| 299 | |
| 300 | <para> |
| 301 | <imagedata fileref="figures/sdk-eclipse-dev-flow.png" |
| 302 | width="7in" depth="7in" align="center" scale="100" /> |
| 303 | </para> |
| 304 | |
| 305 | <para> |
| 306 | <orderedlist> |
| 307 | <listitem><para> |
| 308 | <emphasis>Prepare the host system for the Yocto |
| 309 | Project</emphasis>: |
| 310 | See |
| 311 | "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>" |
| 312 | and |
| 313 | "<ulink url='&YOCTO_DOCS_REF_URL;#required-packages-for-the-host-development-system'>Required Packages for the Host Development System</ulink>" |
| 314 | sections both in the Yocto Project Reference Manual for |
| 315 | requirements. |
| 316 | In particular, be sure your host system has the |
| 317 | <filename>xterm</filename> package installed. |
| 318 | </para></listitem> |
| 319 | <listitem><para> |
| 320 | <emphasis>Secure the Yocto Project kernel target |
| 321 | image</emphasis>: |
| 322 | You must have a target kernel image that has been built |
| 323 | using the OpenEmbedded build system.</para> |
| 324 | <para>Depending on whether the Yocto Project has a |
| 325 | pre-built image that matches your target architecture |
| 326 | and where you are going to run the image while you |
| 327 | develop your application (QEMU or real hardware), the |
| 328 | area from which you get the image differs. |
| 329 | <itemizedlist> |
| 330 | <listitem><para> |
| 331 | Download the image from |
| 332 | <ulink url='&YOCTO_MACHINES_DL_URL;'><filename>machines</filename></ulink> |
| 333 | if your target architecture is supported and |
| 334 | you are going to develop and test your |
| 335 | application on actual hardware. |
| 336 | </para></listitem> |
| 337 | <listitem><para> |
| 338 | Download the image from |
| 339 | <ulink url='&YOCTO_QEMU_DL_URL;'> |
| 340 | <filename>machines/qemu</filename></ulink> if |
| 341 | your target architecture is supported and you |
| 342 | are going to develop and test your application |
| 343 | using the QEMU emulator. |
| 344 | </para></listitem> |
| 345 | <listitem><para> |
| 346 | Build your image if you cannot find a pre-built |
| 347 | image that matches your target architecture. |
| 348 | If your target architecture is similar to a |
| 349 | supported architecture, you can modify the |
| 350 | kernel image before you build it. |
| 351 | See the |
| 352 | "<ulink url='&YOCTO_DOCS_DEV_URL;#patching-the-kernel'>Patching the Kernel</ulink>" |
| 353 | section in the Yocto Project Development |
| 354 | manual for an example. |
| 355 | </para></listitem> |
| 356 | </itemizedlist> |
| 357 | </para></listitem> |
| 358 | <listitem> |
| 359 | <para><emphasis>Install the SDK</emphasis>: |
| 360 | The SDK provides a target-specific cross-development |
| 361 | toolchain, the root filesystem, the QEMU emulator, and |
| 362 | other tools that can help you develop your application. |
| 363 | For information on how to install the SDK, see the |
| 364 | "<link linkend='sdk-installing-the-sdk'>Installing the SDK</link>" |
| 365 | section. |
| 366 | </para></listitem> |
| 367 | <listitem><para> |
| 368 | <emphasis>Secure the target root filesystem |
| 369 | and the Cross-development toolchain</emphasis>: |
| 370 | You need to find and download the appropriate root |
| 371 | filesystem and the cross-development toolchain.</para> |
| 372 | <para>You can find the tarballs for the root filesystem |
| 373 | in the same area used for the kernel image. |
| 374 | Depending on the type of image you are running, the |
| 375 | root filesystem you need differs. |
| 376 | For example, if you are developing an application that |
| 377 | runs on an image that supports Sato, you need to get a |
| 378 | root filesystem that supports Sato.</para> |
| 379 | <para>You can find the cross-development toolchains at |
| 380 | <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'><filename>toolchains</filename></ulink>. |
| 381 | Be sure to get the correct toolchain for your |
| 382 | development host and your target architecture. |
| 383 | See the "<link linkend='sdk-locating-pre-built-sdk-installers'>Locating Pre-Built SDK Installers</link>" |
| 384 | section for information and the |
| 385 | "<link linkend='sdk-installing-the-sdk'>Installing the SDK</link>" |
| 386 | section for installation information. |
| 387 | <note> |
| 388 | As an alternative to downloading an SDK, you can |
| 389 | build the SDK installer. |
| 390 | For information on building the installer, see the |
| 391 | "<link linkend='sdk-building-an-sdk-installer'>Building an SDK Installer</link>" |
| 392 | section. |
| 393 | Another helpful resource for building an installer |
| 394 | is the |
| 395 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>Cookbook guide to Making an Eclipse Debug Capable Image</ulink> |
| 396 | wiki page. |
| 397 | </note> |
| 398 | </para></listitem> |
| 399 | <listitem><para> |
| 400 | <emphasis>Create and build your application</emphasis>: |
| 401 | At this point, you need to have source files for your |
| 402 | application. |
| 403 | Once you have the files, you can use the Eclipse IDE |
| 404 | to import them and build the project. |
| 405 | If you are not using Eclipse, you need to use the |
| 406 | cross-development tools you have installed to create |
| 407 | the image.</para></listitem> |
| 408 | <listitem><para> |
| 409 | <emphasis>Deploy the image with the |
| 410 | application</emphasis>: |
| 411 | Using the Eclipse IDE, you can deploy your image to the |
| 412 | hardware or to QEMU through the project's preferences. |
| 413 | You can also use Eclipse to load and test your image |
| 414 | under QEMU. |
| 415 | See the |
| 416 | "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-manual-qemu'>Using the Quick EMUlator (QEMU)</ulink>" |
| 417 | chapter in the Yocto Project Development Manual |
| 418 | for information on using QEMU. |
| 419 | </para></listitem> |
| 420 | <listitem><para> |
| 421 | <emphasis>Test and debug the application</emphasis>: |
| 422 | Once your application is deployed, you need to test it. |
| 423 | Within the Eclipse IDE, you can use the debugging |
| 424 | environment along with supported performance enhancing |
| 425 | <ulink url='http://www.eclipse.org/linuxtools/'>Linux Tools</ulink>. |
| 426 | </para></listitem> |
| 427 | </orderedlist> |
| 428 | </para> |
| 429 | </section> |
| 430 | |
| 431 | <section id='adt-eclipse'> |
| 432 | <title>Working Within Eclipse</title> |
| 433 | |
| 434 | <para> |
| 435 | The Eclipse IDE is a popular development environment and it |
| 436 | fully supports development using the Yocto Project. |
| 437 | </para> |
| 438 | |
| 439 | <para> |
| 440 | When you install and configure the Eclipse Yocto Project |
| 441 | Plug-in into the Eclipse IDE, you maximize your Yocto |
| 442 | Project experience. |
| 443 | Installing and configuring the Plug-in results in an |
| 444 | environment that has extensions specifically designed to let |
| 445 | you more easily develop software. |
| 446 | These extensions allow for cross-compilation, deployment, and |
| 447 | execution of your output into a QEMU emulation session as well |
| 448 | as actual target hardware. |
| 449 | You can also perform cross-debugging and profiling. |
| 450 | The environment also supports performance enhancing |
| 451 | <ulink url='http://www.eclipse.org/linuxtools/'>tools</ulink> |
| 452 | that allow you to perform remote profiling, tracing, |
| 453 | collection of power data, collection of latency data, and |
| 454 | collection of performance data. |
| 455 | <note> |
| 456 | This release of the Yocto Project supports both the Neon |
| 457 | and Mars versions of the Eclipse IDE. |
| 458 | This section provides information on how to use the Neon |
| 459 | release with the Yocto Project. |
| 460 | For information on how to use the Mars version of Eclipse |
| 461 | with the Yocto Project, see |
| 462 | "<link linkend='sdk-appendix-mars'>Appendix C</link>. |
| 463 | </note> |
| 464 | </para> |
| 465 | |
| 466 | <section id='neon-setting-up-the-eclipse-ide'> |
| 467 | <title>Setting Up the Neon Version of the Eclipse IDE</title> |
| 468 | |
| 469 | <para> |
| 470 | To develop within the Eclipse IDE, you need to do the |
| 471 | following: |
| 472 | <orderedlist> |
| 473 | <listitem><para> |
| 474 | Install the Neon version of the Eclipse IDE. |
| 475 | </para></listitem> |
| 476 | <listitem><para> |
| 477 | Configure the Eclipse IDE. |
| 478 | </para></listitem> |
| 479 | <listitem><para> |
| 480 | Install the Eclipse Yocto Plug-in. |
| 481 | </para></listitem> |
| 482 | <listitem><para> |
| 483 | Configure the Eclipse Yocto Plug-in. |
| 484 | </para></listitem> |
| 485 | </orderedlist> |
| 486 | <note> |
| 487 | Do not install Eclipse from your distribution's package |
| 488 | repository. |
| 489 | Be sure to install Eclipse from the official Eclipse |
| 490 | download site as directed in the next section. |
| 491 | </note> |
| 492 | </para> |
| 493 | |
| 494 | <section id='neon-installing-eclipse-ide'> |
| 495 | <title>Installing the Neon Eclipse IDE</title> |
| 496 | |
| 497 | <para> |
| 498 | Follow these steps to locate, install, and configure |
| 499 | Neon Eclipse: |
| 500 | <orderedlist> |
| 501 | <listitem><para> |
| 502 | <emphasis>Locate the Neon Download:</emphasis> |
| 503 | Open a browser and go to |
| 504 | <ulink url='http://www.eclipse.org/mars/'>http://www.eclipse.org/neon/</ulink>. |
| 505 | </para></listitem> |
| 506 | <listitem><para> |
| 507 | <emphasis>Download the Tarball:</emphasis> |
| 508 | Click through the "Download" buttons to |
| 509 | download the file. |
| 510 | </para></listitem> |
| 511 | <listitem><para> |
| 512 | <emphasis>Unpack the Tarball:</emphasis> |
| 513 | Move to a clean directory and unpack the |
| 514 | tarball. |
| 515 | Here is an example: |
| 516 | <literallayout class='monospaced'> |
| 517 | $ cd ~ |
| 518 | $ tar -xzvf ~/Downloads/eclipse-inst-linux64.tar.gz |
| 519 | </literallayout> |
| 520 | Everything unpacks into a folder named |
| 521 | "eclipse-installer". |
| 522 | </para></listitem> |
| 523 | <listitem><para> |
| 524 | <emphasis>Launch the Installer:</emphasis> |
| 525 | Use the following commands to launch the |
| 526 | installer: |
| 527 | <literallayout class='monospaced'> |
| 528 | $ cd ~/eclipse-installer |
| 529 | $ ./eclipse-inst |
| 530 | </literallayout> |
| 531 | </para></listitem> |
| 532 | <listitem><para> |
| 533 | <emphasis>Select Your IDE:</emphasis> |
| 534 | From the list, select the "Eclipse IDE for |
| 535 | C/C++ Developers". |
| 536 | </para></listitem> |
| 537 | <listitem><para> |
| 538 | <emphasis>Install the Software:</emphasis> |
| 539 | Accept the default "cpp-neon" directory and |
| 540 | click "Install". |
| 541 | Accept any license agreements and approve any |
| 542 | certificates. |
| 543 | </para></listitem> |
| 544 | <listitem><para> |
| 545 | <emphasis>Launch Neon:</emphasis> |
| 546 | Click the "Launch" button and accept the |
| 547 | default "workspace". |
| 548 | </para></listitem> |
| 549 | </orderedlist> |
| 550 | </para> |
| 551 | </section> |
| 552 | |
| 553 | <section id='neon-configuring-the-mars-eclipse-ide'> |
| 554 | <title>Configuring the Neon Eclipse IDE</title> |
| 555 | |
| 556 | <para> |
| 557 | Follow these steps to configure the Neon Eclipse IDE. |
| 558 | <note> |
| 559 | Depending on how you installed Eclipse and what |
| 560 | you have already done, some of the options will |
| 561 | not appear. |
| 562 | If you cannot find an option as directed by the |
| 563 | manual, it has already been installed. |
| 564 | </note> |
| 565 | <orderedlist> |
| 566 | <listitem><para> |
| 567 | Be sure Eclipse is running and you are in your |
| 568 | workbench. |
| 569 | </para></listitem> |
| 570 | <listitem><para> |
| 571 | Select "Install New Software" from the "Help" |
| 572 | pull-down menu. |
| 573 | </para></listitem> |
| 574 | <listitem><para> |
| 575 | Select |
| 576 | "Neon - http://download.eclipse.org/releases/neon" |
| 577 | from the "Work with:" pull-down menu. |
| 578 | </para></listitem> |
| 579 | <listitem><para> |
| 580 | Expand the box next to "Linux Tools" and select |
| 581 | the following: |
| 582 | <literallayout class='monospaced'> |
| 583 | C/C++ Remote (Over TCF/TE) Run/Debug Launcher |
| 584 | TM Terminal |
| 585 | </literallayout> |
| 586 | </para></listitem> |
| 587 | <listitem><para> |
| 588 | Expand the box next to "Mobile and Device |
| 589 | Development" and select the following |
| 590 | boxes: |
| 591 | <literallayout class='monospaced'> |
| 592 | C/C++ Remote (Over TCF/TE) Run/Debug Launcher |
| 593 | Remote System Explorer User Actions |
| 594 | TM Terminal |
| 595 | TCF Remote System Explorer add-in |
| 596 | TCF Target Explorer |
| 597 | </literallayout> |
| 598 | </para></listitem> |
| 599 | <listitem><para> |
| 600 | Expand the box next to "Programming Languages" |
| 601 | and select the following box: |
| 602 | <literallayout class='monospaced'> |
| 603 | C/C++ Development Tools SDK |
| 604 | </literallayout> |
| 605 | </para></listitem> |
| 606 | <listitem><para> |
| 607 | Complete the installation by clicking through |
| 608 | appropriate "Next" and "Finish" buttons. |
| 609 | </para></listitem> |
| 610 | </orderedlist> |
| 611 | </para> |
| 612 | </section> |
| 613 | |
| 614 | <section id='neon-installing-the-eclipse-yocto-plug-in'> |
| 615 | <title>Installing or Accessing the Neon Eclipse Yocto Plug-in</title> |
| 616 | |
| 617 | <para> |
| 618 | You can install the Eclipse Yocto Plug-in into the |
| 619 | Eclipse IDE one of two ways: use the Yocto Project's |
| 620 | Eclipse Update site to install the pre-built plug-in |
| 621 | or build and install the plug-in from the latest |
| 622 | source code. |
| 623 | </para> |
| 624 | |
| 625 | <section id='neon-new-software'> |
| 626 | <title>Installing the Pre-built Plug-in from the Yocto Project Eclipse Update Site</title> |
| 627 | |
| 628 | <para> |
| 629 | To install the Neon Eclipse Yocto Plug-in from the |
| 630 | update site, follow these steps: |
| 631 | <orderedlist> |
| 632 | <listitem><para> |
| 633 | Start up the Eclipse IDE. |
| 634 | </para></listitem> |
| 635 | <listitem><para> |
| 636 | In Eclipse, select "Install New |
| 637 | Software" from the "Help" menu. |
| 638 | </para></listitem> |
| 639 | <listitem><para> |
| 640 | Click "Add..." in the "Work with:" area. |
| 641 | </para></listitem> |
| 642 | <listitem><para> |
| 643 | Enter |
| 644 | <filename>&ECLIPSE_DL_PLUGIN_URL;/neon</filename> |
| 645 | in the URL field and provide a meaningful |
| 646 | name in the "Name" field. |
| 647 | </para></listitem> |
| 648 | <listitem><para> |
| 649 | Click "OK" to have the entry added |
| 650 | to the "Work with:" drop-down list. |
| 651 | </para></listitem> |
| 652 | <listitem><para> |
| 653 | Select the entry for the plug-in |
| 654 | from the "Work with:" drop-down list. |
| 655 | </para></listitem> |
| 656 | <listitem><para> |
| 657 | Check the boxes next to the following: |
| 658 | <literallayout class='monospaced'> |
| 659 | Yocto Project SDK Plug-in |
| 660 | Yocto Project Documentation plug-in |
| 661 | </literallayout> |
| 662 | </para></listitem> |
| 663 | <listitem><para> |
| 664 | Complete the remaining software |
| 665 | installation steps and then restart the |
| 666 | Eclipse IDE to finish the installation of |
| 667 | the plug-in. |
| 668 | <note> |
| 669 | You can click "OK" when prompted about |
| 670 | installing software that contains |
| 671 | unsigned content. |
| 672 | </note> |
| 673 | </para></listitem> |
| 674 | </orderedlist> |
| 675 | </para> |
| 676 | </section> |
| 677 | |
| 678 | <section id='neon-zip-file-method'> |
| 679 | <title>Installing the Plug-in Using the Latest Source Code</title> |
| 680 | |
| 681 | <para> |
| 682 | To install the Neon Eclipse Yocto Plug-in from the |
| 683 | latest source code, follow these steps: |
| 684 | <orderedlist> |
| 685 | <listitem><para> |
| 686 | Be sure your development system |
| 687 | has JDK 1.8+ |
| 688 | </para></listitem> |
| 689 | <listitem><para> |
| 690 | Install X11-related packages: |
| 691 | <literallayout class='monospaced'> |
| 692 | $ sudo apt-get install xauth |
| 693 | </literallayout> |
| 694 | </para></listitem> |
| 695 | <listitem><para> |
| 696 | In a new terminal shell, create a |
| 697 | Git repository with: |
| 698 | <literallayout class='monospaced'> |
| 699 | $ cd ~ |
| 700 | $ git clone git://git.yoctoproject.org/eclipse-poky |
| 701 | </literallayout> |
| 702 | </para></listitem> |
| 703 | <listitem><para> |
| 704 | Use Git to create the correct tag: |
| 705 | <literallayout class='monospaced'> |
| 706 | $ cd ~/eclipse-poky |
| 707 | $ git checkout neon/yocto-&DISTRO; |
| 708 | </literallayout> |
| 709 | This creates a local tag named |
| 710 | <filename>neon/yocto-&DISTRO;</filename> |
| 711 | based on the branch |
| 712 | <filename>origin/neon-master</filename>. |
| 713 | You are put into a detached HEAD state, |
| 714 | which is fine since you are only going to |
| 715 | be building and not developing. |
| 716 | </para></listitem> |
| 717 | <listitem><para> |
| 718 | Change to the <filename>scripts</filename> |
| 719 | directory within the Git repository: |
| 720 | <literallayout class='monospaced'> |
| 721 | $ cd scripts |
| 722 | </literallayout> |
| 723 | </para></listitem> |
| 724 | <listitem><para> |
| 725 | Set up the local build environment |
| 726 | by running the setup script: |
| 727 | <literallayout class='monospaced'> |
| 728 | $ ./setup.sh |
| 729 | </literallayout> |
| 730 | When the script finishes execution, |
| 731 | it prompts you with instructions on how to |
| 732 | run the <filename>build.sh</filename> |
| 733 | script, which is also in the |
| 734 | <filename>scripts</filename> directory of |
| 735 | the Git repository created earlier. |
| 736 | </para></listitem> |
| 737 | <listitem><para> |
| 738 | Run the <filename>build.sh</filename> |
| 739 | script as directed. |
| 740 | Be sure to provide the tag name, |
| 741 | documentation branch, and a release name. |
| 742 | </para> |
| 743 | <para> |
| 744 | Following is an example: |
| 745 | <literallayout class='monospaced'> |
| 746 | $ ECLIPSE_HOME=/home/scottrif/eclipse-poky/scripts/eclipse ./build.sh -l neon/yocto-&DISTRO; master yocto-&DISTRO; 2>&1 | tee build.log |
| 747 | </literallayout> |
| 748 | The previous example command adds the tag |
| 749 | you need for |
| 750 | <filename>mars/yocto-&DISTRO;</filename> |
| 751 | to <filename>HEAD</filename>, then tells |
| 752 | the build script to use the local (-l) Git |
| 753 | checkout for the build. |
| 754 | After running the script, the file |
| 755 | <filename>org.yocto.sdk-</filename><replaceable>release</replaceable><filename>-</filename><replaceable>date</replaceable><filename>-archive.zip</filename> |
| 756 | is in the current directory. |
| 757 | </para></listitem> |
| 758 | <listitem><para> |
| 759 | If necessary, start the Eclipse IDE |
| 760 | and be sure you are in the Workbench. |
| 761 | </para></listitem> |
| 762 | <listitem><para> |
| 763 | Select "Install New Software" from |
| 764 | the "Help" pull-down menu. |
| 765 | </para></listitem> |
| 766 | <listitem><para> |
| 767 | Click "Add". |
| 768 | </para></listitem> |
| 769 | <listitem><para> |
| 770 | Provide anything you want in the |
| 771 | "Name" field. |
| 772 | </para></listitem> |
| 773 | <listitem><para> |
| 774 | Click "Archive" and browse to the |
| 775 | ZIP file you built earlier. |
| 776 | This ZIP file should not be "unzipped", and |
| 777 | must be the |
| 778 | <filename>*archive.zip</filename> file |
| 779 | created by running the |
| 780 | <filename>build.sh</filename> script. |
| 781 | </para></listitem> |
| 782 | <listitem><para> |
| 783 | Click the "OK" button. |
| 784 | </para></listitem> |
| 785 | <listitem><para> |
| 786 | Check the boxes that appear in |
| 787 | the installation window to install the |
| 788 | following: |
| 789 | <literallayout class='monospaced'> |
| 790 | Yocto Project SDK Plug-in |
| 791 | Yocto Project Documentation plug-in |
| 792 | </literallayout> |
| 793 | </para></listitem> |
| 794 | <listitem><para> |
| 795 | Finish the installation by clicking |
| 796 | through the appropriate buttons. |
| 797 | You can click "OK" when prompted about |
| 798 | installing software that contains unsigned |
| 799 | content. |
| 800 | </para></listitem> |
| 801 | <listitem><para> |
| 802 | Restart the Eclipse IDE if necessary. |
| 803 | </para></listitem> |
| 804 | </orderedlist> |
| 805 | </para> |
| 806 | |
| 807 | <para> |
| 808 | At this point you should be able to configure the |
| 809 | Eclipse Yocto Plug-in as described in the |
| 810 | "<link linkend='mars-configuring-the-eclipse-yocto-plug-in'>Configuring the Neon Eclipse Yocto Plug-in</link>" |
| 811 | section. |
| 812 | </para> |
| 813 | </section> |
| 814 | </section> |
| 815 | |
| 816 | <section id='neon-configuring-the-eclipse-yocto-plug-in'> |
| 817 | <title>Configuring the Neon Eclipse Yocto Plug-in</title> |
| 818 | |
| 819 | <para> |
| 820 | Configuring the Neon Eclipse Yocto Plug-in involves |
| 821 | setting the Cross Compiler options and the Target |
| 822 | options. |
| 823 | The configurations you choose become the default |
| 824 | settings for all projects. |
| 825 | You do have opportunities to change them later when |
| 826 | you configure the project (see the following section). |
| 827 | </para> |
| 828 | |
| 829 | <para> |
| 830 | To start, you need to do the following from within the |
| 831 | Eclipse IDE: |
| 832 | <itemizedlist> |
| 833 | <listitem><para> |
| 834 | Choose "Preferences" from the "Window" menu to |
| 835 | display the Preferences Dialog. |
| 836 | </para></listitem> |
| 837 | <listitem><para> |
| 838 | Click "Yocto Project SDK" to display |
| 839 | the configuration screen. |
| 840 | </para></listitem> |
| 841 | </itemizedlist> |
| 842 | The following sub-sections describe how to configure |
| 843 | the plug-in. |
| 844 | <note> |
| 845 | Throughout the descriptions, a start-to-finish |
| 846 | example for preparing a QEMU image for use with |
| 847 | Eclipse is referenced as the "wiki" and is linked |
| 848 | to the example on the |
| 849 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'> Cookbook guide to Making an Eclipse Debug Capable Image</ulink> |
| 850 | wiki page. |
| 851 | </note> |
| 852 | </para> |
| 853 | |
| 854 | <section id='neon-configuring-the-cross-compiler-options'> |
| 855 | <title>Configuring the Cross-Compiler Options</title> |
| 856 | |
| 857 | <para> |
| 858 | Cross Compiler options enable Eclipse to use your |
| 859 | specific cross compiler toolchain. |
| 860 | To configure these options, you must select |
| 861 | the type of toolchain, point to the toolchain, |
| 862 | specify the sysroot location, and select the target |
| 863 | architecture. |
| 864 | <itemizedlist> |
| 865 | <listitem><para> |
| 866 | <emphasis>Selecting the Toolchain |
| 867 | Type:</emphasis> |
| 868 | Choose between |
| 869 | <filename>Standalone pre-built toolchain</filename> |
| 870 | and |
| 871 | <filename>Build system derived toolchain</filename> |
| 872 | for Cross Compiler Options. |
| 873 | <itemizedlist> |
| 874 | <listitem><para> |
| 875 | <emphasis> |
| 876 | <filename>Standalone Pre-built Toolchain:</filename> |
| 877 | </emphasis> |
| 878 | Select this type when you are using |
| 879 | a stand-alone cross-toolchain. |
| 880 | For example, suppose you are an |
| 881 | application developer and do not |
| 882 | need to build a target image. |
| 883 | Instead, you just want to use an |
| 884 | architecture-specific toolchain on |
| 885 | an existing kernel and target root |
| 886 | filesystem. |
| 887 | In other words, you have downloaded |
| 888 | and installed a pre-built toolchain |
| 889 | for an existing image. |
| 890 | </para></listitem> |
| 891 | <listitem><para> |
| 892 | <emphasis> |
| 893 | <filename>Build System Derived Toolchain:</filename> |
| 894 | </emphasis> |
| 895 | Select this type if you built the |
| 896 | toolchain as part of the |
| 897 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>. |
| 898 | When you select |
| 899 | <filename>Build system derived toolchain</filename>, |
| 900 | you are using the toolchain built |
| 901 | and bundled inside the Build |
| 902 | Directory. |
| 903 | For example, suppose you created a |
| 904 | suitable image using the steps in the |
| 905 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>wiki</ulink>. |
| 906 | In this situation, you would select |
| 907 | the |
| 908 | <filename>Build system derived toolchain</filename>. |
| 909 | </para></listitem> |
| 910 | </itemizedlist> |
| 911 | </para></listitem> |
| 912 | <listitem><para> |
| 913 | <emphasis>Specify the Toolchain Root |
| 914 | Location:</emphasis> |
| 915 | If you are using a stand-alone pre-built |
| 916 | toolchain, you should be pointing to where |
| 917 | it is installed (e.g. |
| 918 | <filename>/opt/poky/&DISTRO;</filename>). |
| 919 | See the |
| 920 | "<link linkend='sdk-installing-the-sdk'>Installing the SDK</link>" |
| 921 | section for information about how the SDK is |
| 922 | installed.</para> |
| 923 | <para>If you are using a build system |
| 924 | derived toolchain, the path you provide for |
| 925 | the |
| 926 | <filename>Toolchain Root Location</filename> |
| 927 | field is the |
| 928 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> |
| 929 | from which you run the |
| 930 | <filename>bitbake</filename> command (e.g |
| 931 | <filename>/home/scottrif/poky/build</filename>). |
| 932 | </para> |
| 933 | <para>For more information, see the |
| 934 | "<link linkend='sdk-building-an-sdk-installer'>Building an SDK Installer</link>" |
| 935 | section. |
| 936 | </para></listitem> |
| 937 | <listitem><para> |
| 938 | <emphasis>Specify Sysroot Location: |
| 939 | </emphasis> |
| 940 | This location is where the root filesystem |
| 941 | for the target hardware resides. |
| 942 | </para> |
| 943 | <para>This location depends on where you |
| 944 | separately extracted and installed the |
| 945 | target filesystem. |
| 946 | As an example, suppose you prepared an |
| 947 | image using the steps in the |
| 948 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>wiki</ulink>. |
| 949 | If so, the |
| 950 | <filename>MY_QEMU_ROOTFS</filename> |
| 951 | directory is found in the |
| 952 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> |
| 953 | and you would browse to and select that |
| 954 | directory (e.g. |
| 955 | <filename>/home/scottrif/poky/build/MY_QEMU_ROOTFS</filename>). |
| 956 | </para> |
| 957 | <para>For more information on how to |
| 958 | install the toolchain and on how to extract |
| 959 | and install the sysroot filesystem, see the |
| 960 | "<link linkend='sdk-building-an-sdk-installer'>Building an SDK Installer</link>" |
| 961 | section. |
| 962 | </para></listitem> |
| 963 | <listitem><para> |
| 964 | <emphasis>Select the Target Architecture: |
| 965 | </emphasis> |
| 966 | The target architecture is the type of |
| 967 | hardware you are going to use or emulate. |
| 968 | Use the pull-down |
| 969 | <filename>Target Architecture</filename> |
| 970 | menu to make your selection. |
| 971 | The pull-down menu should have the |
| 972 | supported architectures. |
| 973 | If the architecture you need is not listed |
| 974 | in the menu, you will need to build the |
| 975 | image. |
| 976 | See the |
| 977 | "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>" |
| 978 | section of the Yocto Project Quick Start |
| 979 | for more information. |
| 980 | You can also see the |
| 981 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>wiki</ulink>. |
| 982 | </para></listitem> |
| 983 | </itemizedlist> |
| 984 | </para> |
| 985 | </section> |
| 986 | |
| 987 | <section id='neon-configuring-the-target-options'> |
| 988 | <title>Configuring the Target Options</title> |
| 989 | |
| 990 | <para> |
| 991 | You can choose to emulate hardware using the QEMU |
| 992 | emulator, or you can choose to run your image on |
| 993 | actual hardware. |
| 994 | <itemizedlist> |
| 995 | <listitem><para> |
| 996 | <emphasis>QEMU:</emphasis> |
| 997 | Select this option if you will be using the |
| 998 | QEMU emulator. |
| 999 | If you are using the emulator, you also |
| 1000 | need to locate the kernel and specify any |
| 1001 | custom options.</para> |
| 1002 | <para>If you selected the |
| 1003 | <filename>Build system derived toolchain</filename>, |
| 1004 | the target kernel you built will be located |
| 1005 | in the |
| 1006 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> |
| 1007 | in |
| 1008 | <filename>tmp/deploy/images/<replaceable>machine</replaceable></filename> |
| 1009 | directory. |
| 1010 | As an example, suppose you performed the |
| 1011 | steps in the |
| 1012 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>wiki</ulink>. |
| 1013 | In this case, you specify your Build |
| 1014 | Directory path followed by the image (e.g. |
| 1015 | <filename>/home/scottrif/poky/build/tmp/deploy/images/qemux86/bzImage-qemux86.bin</filename>). |
| 1016 | </para> |
| 1017 | <para>If you selected the standalone |
| 1018 | pre-built toolchain, the pre-built image |
| 1019 | you downloaded is located in the directory |
| 1020 | you specified when you downloaded the |
| 1021 | image.</para> |
| 1022 | <para>Most custom options are for advanced |
| 1023 | QEMU users to further customize their QEMU |
| 1024 | instance. |
| 1025 | These options are specified between paired |
| 1026 | angled brackets. |
| 1027 | Some options must be specified outside the |
| 1028 | brackets. |
| 1029 | In particular, the options |
| 1030 | <filename>serial</filename>, |
| 1031 | <filename>nographic</filename>, and |
| 1032 | <filename>kvm</filename> must all be |
| 1033 | outside the brackets. |
| 1034 | Use the <filename>man qemu</filename> |
| 1035 | command to get help on all the options and |
| 1036 | their use. |
| 1037 | The following is an example: |
| 1038 | <literallayout class='monospaced'> |
| 1039 | serial ‘<-m 256 -full-screen>’ |
| 1040 | </literallayout></para> |
| 1041 | <para> |
| 1042 | Regardless of the mode, Sysroot is already |
| 1043 | defined as part of the Cross-Compiler |
| 1044 | Options configuration in the |
| 1045 | <filename>Sysroot Location:</filename> |
| 1046 | field. |
| 1047 | </para></listitem> |
| 1048 | <listitem><para> |
| 1049 | <emphasis>External HW:</emphasis> |
| 1050 | Select this option if you will be using |
| 1051 | actual hardware.</para></listitem> |
| 1052 | </itemizedlist> |
| 1053 | </para> |
| 1054 | |
| 1055 | <para> |
| 1056 | Click the "Apply" and "OK" to save your plug-in |
| 1057 | configurations. |
| 1058 | </para> |
| 1059 | </section> |
| 1060 | </section> |
| 1061 | </section> |
| 1062 | |
| 1063 | <section id='neon-creating-the-project'> |
| 1064 | <title>Creating the Project</title> |
| 1065 | |
| 1066 | <para> |
| 1067 | You can create two types of projects: Autotools-based, or |
| 1068 | Makefile-based. |
| 1069 | This section describes how to create Autotools-based |
| 1070 | projects from within the Eclipse IDE. |
| 1071 | For information on creating Makefile-based projects in a |
| 1072 | terminal window, see the |
| 1073 | "<link linkend='makefile-based-projects'>Makefile-Based Projects</link>" |
| 1074 | section. |
| 1075 | <note> |
| 1076 | Do not use special characters in project names |
| 1077 | (e.g. spaces, underscores, etc.). Doing so can |
| 1078 | cause configuration to fail. |
| 1079 | </note> |
| 1080 | </para> |
| 1081 | |
| 1082 | <para> |
| 1083 | To create a project based on a Yocto template and then |
| 1084 | display the source code, follow these steps: |
| 1085 | <orderedlist> |
| 1086 | <listitem><para> |
| 1087 | Select "C Project" from the "File -> New" menu. |
| 1088 | </para></listitem> |
| 1089 | <listitem><para> |
| 1090 | Expand |
| 1091 | <filename>Yocto Project SDK Autotools Project</filename>. |
| 1092 | </para></listitem> |
| 1093 | <listitem><para> |
| 1094 | Select <filename>Hello World ANSI C Autotools Projects</filename>. |
| 1095 | This is an Autotools-based project based on a Yocto |
| 1096 | template. |
| 1097 | </para></listitem> |
| 1098 | <listitem><para> |
| 1099 | Put a name in the |
| 1100 | <filename>Project name:</filename> field. |
| 1101 | Do not use hyphens as part of the name |
| 1102 | (e.g. <filename>hello</filename>). |
| 1103 | </para></listitem> |
| 1104 | <listitem><para> |
| 1105 | Click "Next". |
| 1106 | </para></listitem> |
| 1107 | <listitem><para> |
| 1108 | Add appropriate information in the various fields. |
| 1109 | </para></listitem> |
| 1110 | <listitem><para> |
| 1111 | Click "Finish". |
| 1112 | </para></listitem> |
| 1113 | <listitem><para> |
| 1114 | If the "open perspective" prompt appears, |
| 1115 | click "Yes" so that you in the C/C++ perspective. |
| 1116 | </para></listitem> |
| 1117 | <listitem><para>The left-hand navigation pane shows |
| 1118 | your project. |
| 1119 | You can display your source by double clicking the |
| 1120 | project's source file. |
| 1121 | </para></listitem> |
| 1122 | </orderedlist> |
| 1123 | </para> |
| 1124 | </section> |
| 1125 | |
| 1126 | <section id='neon-configuring-the-cross-toolchains'> |
| 1127 | <title>Configuring the Cross-Toolchains</title> |
| 1128 | |
| 1129 | <para> |
| 1130 | The earlier section, |
| 1131 | "<link linkend='neon-configuring-the-eclipse-yocto-plug-in'>Configuring the Neon Eclipse Yocto Plug-in</link>", |
| 1132 | sets up the default project configurations. |
| 1133 | You can override these settings for a given project by |
| 1134 | following these steps: |
| 1135 | <orderedlist> |
| 1136 | <listitem><para> |
| 1137 | Select "Yocto Project Settings" from |
| 1138 | the "Project -> Properties" menu. |
| 1139 | This selection brings up the Yocto Project Settings |
| 1140 | Dialog and allows you to make changes specific to |
| 1141 | an individual project.</para> |
| 1142 | <para>By default, the Cross Compiler Options and |
| 1143 | Target Options for a project are inherited from |
| 1144 | settings you provided using the Preferences Dialog |
| 1145 | as described earlier in the |
| 1146 | "<link linkend='neon-configuring-the-eclipse-yocto-plug-in'>Configuring the Neon Eclipse Yocto Plug-in</link>" |
| 1147 | section. |
| 1148 | The Yocto Project Settings Dialog allows you to |
| 1149 | override those default settings for a given |
| 1150 | project. |
| 1151 | </para></listitem> |
| 1152 | <listitem><para> |
| 1153 | Make or verify your configurations for the |
| 1154 | project and click "OK". |
| 1155 | </para></listitem> |
| 1156 | <listitem><para> |
| 1157 | Right-click in the navigation pane and |
| 1158 | select "Reconfigure Project" from the pop-up menu. |
| 1159 | This selection reconfigures the project by running |
| 1160 | <filename>autogen.sh</filename> in the workspace |
| 1161 | for your project. |
| 1162 | The script also runs |
| 1163 | <filename>libtoolize</filename>, |
| 1164 | <filename>aclocal</filename>, |
| 1165 | <filename>autoconf</filename>, |
| 1166 | <filename>autoheader</filename>, |
| 1167 | <filename>automake --a</filename>, and |
| 1168 | <filename>./configure</filename>. |
| 1169 | Click on the "Console" tab beneath your source code |
| 1170 | to see the results of reconfiguring your project. |
| 1171 | </para></listitem> |
| 1172 | </orderedlist> |
| 1173 | </para> |
| 1174 | </section> |
| 1175 | |
| 1176 | <section id='neon-building-the-project'> |
| 1177 | <title>Building the Project</title> |
| 1178 | |
| 1179 | <para> |
| 1180 | To build the project select "Build All" from the |
| 1181 | "Project" menu. |
| 1182 | The console should update and you can note the |
| 1183 | cross-compiler you are using. |
| 1184 | <note> |
| 1185 | When building "Yocto Project SDK Autotools" projects, |
| 1186 | the Eclipse IDE might display error messages for |
| 1187 | Functions/Symbols/Types that cannot be "resolved", |
| 1188 | even when the related include file is listed at the |
| 1189 | project navigator and when the project is able to |
| 1190 | build. |
| 1191 | For these cases only, it is recommended to add a new |
| 1192 | linked folder to the appropriate sysroot. |
| 1193 | Use these steps to add the linked folder: |
| 1194 | <orderedlist> |
| 1195 | <listitem><para> |
| 1196 | Select the project. |
| 1197 | </para></listitem> |
| 1198 | <listitem><para> |
| 1199 | Select "Folder" from the |
| 1200 | <filename>File > New</filename> menu. |
| 1201 | </para></listitem> |
| 1202 | <listitem><para> |
| 1203 | In the "New Folder" Dialog, select "Link to |
| 1204 | alternate location (linked folder)". |
| 1205 | </para></listitem> |
| 1206 | <listitem><para> |
| 1207 | Click "Browse" to navigate to the include |
| 1208 | folder inside the same sysroot location |
| 1209 | selected in the Yocto Project |
| 1210 | configuration preferences. |
| 1211 | </para></listitem> |
| 1212 | <listitem><para> |
| 1213 | Click "OK". |
| 1214 | </para></listitem> |
| 1215 | <listitem><para> |
| 1216 | Click "Finish" to save the linked folder. |
| 1217 | </para></listitem> |
| 1218 | </orderedlist> |
| 1219 | </note> |
| 1220 | </para> |
| 1221 | </section> |
| 1222 | |
| 1223 | <section id='neon-starting-qemu-in-user-space-nfs-mode'> |
| 1224 | <title>Starting QEMU in User-Space NFS Mode</title> |
| 1225 | |
| 1226 | <para> |
| 1227 | To start the QEMU emulator from within Eclipse, follow |
| 1228 | these steps: |
| 1229 | <note> |
| 1230 | See the |
| 1231 | "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-manual-qemu'>Using the Quick EMUlator (QEMU)</ulink>" |
| 1232 | chapter in the Yocto Project Development Manual |
| 1233 | for more information on using QEMU. |
| 1234 | </note> |
| 1235 | <orderedlist> |
| 1236 | <listitem><para>Expose and select "External Tools |
| 1237 | Configurations ..." from the "Run -> External |
| 1238 | Tools" menu. |
| 1239 | </para></listitem> |
| 1240 | <listitem><para> |
| 1241 | Locate and select your image in the navigation |
| 1242 | panel to the left |
| 1243 | (e.g. <filename>qemu_i586-poky-linux</filename>). |
| 1244 | </para></listitem> |
| 1245 | <listitem><para> |
| 1246 | Click "Run" to launch QEMU. |
| 1247 | <note> |
| 1248 | The host on which you are running QEMU must |
| 1249 | have the <filename>rpcbind</filename> utility |
| 1250 | running to be able to make RPC calls on a |
| 1251 | server on that machine. |
| 1252 | If QEMU does not invoke and you receive error |
| 1253 | messages involving |
| 1254 | <filename>rpcbind</filename>, follow the |
| 1255 | suggestions to get the service running. |
| 1256 | As an example, on a new Ubuntu 16.04 LTS |
| 1257 | installation, you must do the following in |
| 1258 | order to get QEMU to launch: |
| 1259 | <literallayout class='monospaced'> |
| 1260 | $ sudo apt-get install rpcbind |
| 1261 | </literallayout> |
| 1262 | After installing <filename>rpcbind</filename>, |
| 1263 | you need to edit the |
| 1264 | <filename>/etc/init.d/rpcbind</filename> file |
| 1265 | to include the following line: |
| 1266 | <literallayout class='monospaced'> |
| 1267 | OPTIONS="-i -w" |
| 1268 | </literallayout> |
| 1269 | After modifying the file, you need to start the |
| 1270 | service: |
| 1271 | <literallayout class='monospaced'> |
| 1272 | $ sudo service portmap restart |
| 1273 | </literallayout> |
| 1274 | </note> |
| 1275 | </para></listitem> |
| 1276 | <listitem><para> |
| 1277 | If needed, enter your host root password in |
| 1278 | the shell window at the prompt. |
| 1279 | This sets up a <filename>Tap 0</filename> |
| 1280 | connection needed for running in user-space NFS |
| 1281 | mode. |
| 1282 | </para></listitem> |
| 1283 | <listitem><para> |
| 1284 | Wait for QEMU to launch. |
| 1285 | </para></listitem> |
| 1286 | <listitem><para> |
| 1287 | Once QEMU launches, you can begin operating |
| 1288 | within that environment. |
| 1289 | One useful task at this point would be to determine |
| 1290 | the IP Address for the user-space NFS by using the |
| 1291 | <filename>ifconfig</filename> command. |
| 1292 | The IP address of the QEMU machine appears in the |
| 1293 | xterm window. |
| 1294 | You can use this address to help you see which |
| 1295 | particular |
| 1296 | IP address the instance of QEMU is using. |
| 1297 | </para></listitem> |
| 1298 | </orderedlist> |
| 1299 | </para> |
| 1300 | </section> |
| 1301 | |
| 1302 | <section id='neon-deploying-and-debugging-the-application'> |
| 1303 | <title>Deploying and Debugging the Application</title> |
| 1304 | |
| 1305 | <para> |
| 1306 | Once the QEMU emulator is running the image, you can deploy |
| 1307 | your application using the Eclipse IDE and then use |
| 1308 | the emulator to perform debugging. |
| 1309 | Follow these steps to deploy the application. |
| 1310 | <note> |
| 1311 | Currently, Eclipse does not support SSH port |
| 1312 | forwarding. |
| 1313 | Consequently, if you need to run or debug a remote |
| 1314 | application using the host display, you must create a |
| 1315 | tunneling connection from outside Eclipse and keep |
| 1316 | that connection alive during your work. |
| 1317 | For example, in a new terminal, run the following: |
| 1318 | <literallayout class='monospaced'> |
| 1319 | $ ssh -XY <replaceable>user_name</replaceable>@<replaceable>remote_host_ip</replaceable> |
| 1320 | </literallayout> |
| 1321 | Using the above form, here is an example: |
| 1322 | <literallayout class='monospaced'> |
| 1323 | $ ssh -XY root@192.168.7.2 |
| 1324 | </literallayout> |
| 1325 | After running the command, add the command to be |
| 1326 | executed in Eclipse's run configuration before the |
| 1327 | application as follows: |
| 1328 | <literallayout class='monospaced'> |
| 1329 | export DISPLAY=:10.0 |
| 1330 | </literallayout> |
| 1331 | Be sure to not destroy the connection during your QEMU |
| 1332 | session (i.e. do not |
| 1333 | exit out of or close that shell). |
| 1334 | </note> |
| 1335 | <orderedlist> |
| 1336 | <listitem><para> |
| 1337 | Select "Debug Configurations..." from the |
| 1338 | "Run" menu. |
| 1339 | </para></listitem> |
| 1340 | <listitem><para> |
| 1341 | In the left area, expand |
| 1342 | <filename>C/C++Remote Application</filename>. |
| 1343 | </para></listitem> |
| 1344 | <listitem><para> |
| 1345 | Locate your project and select it to bring |
| 1346 | up a new tabbed view in the Debug Configurations |
| 1347 | Dialog. |
| 1348 | </para></listitem> |
| 1349 | <listitem><para> |
| 1350 | Click on the "Debugger" tab to see the |
| 1351 | cross-tool debugger you are using. |
| 1352 | Be sure to change to the debugger perspective in |
| 1353 | Eclipse. |
| 1354 | </para></listitem> |
| 1355 | <listitem><para> |
| 1356 | Click on the "Main" tab. |
| 1357 | </para></listitem> |
| 1358 | <listitem><para> |
| 1359 | Create a new connection to the QEMU instance |
| 1360 | by clicking on "new".</para></listitem> |
| 1361 | <listitem><para>Select <filename>SSH</filename>, which |
| 1362 | means Secure Socket Shell and then click "OK". |
| 1363 | Optionally, you can select an TCF connection |
| 1364 | instead. |
| 1365 | </para></listitem> |
| 1366 | <listitem><para> |
| 1367 | Clear out the "Connection name" field and |
| 1368 | enter any name you want for the connection. |
| 1369 | </para></listitem> |
| 1370 | <listitem><para> |
| 1371 | Put the IP address for the connection in |
| 1372 | the "Host" field. |
| 1373 | For QEMU, the default is |
| 1374 | <filename>192.168.7.2</filename>. |
| 1375 | However, if a previous QEMU session did not exit |
| 1376 | cleanly, the IP address increments (e.g. |
| 1377 | <filename>192.168.7.3</filename>). |
| 1378 | <note> |
| 1379 | You can find the IP address for the current |
| 1380 | QEMU session by looking in the xterm that |
| 1381 | opens when you launch QEMU. |
| 1382 | </note> |
| 1383 | </para></listitem> |
| 1384 | <listitem><para> |
| 1385 | Enter <filename>root</filename>, which |
| 1386 | is the default for QEMU, for the "User" field. |
| 1387 | Be sure to leave the password field empty. |
| 1388 | </para></listitem> |
| 1389 | <listitem><para> |
| 1390 | Click "Finish" to close the New Connections Dialog. |
| 1391 | </para></listitem> |
| 1392 | <listitem><para> |
| 1393 | If necessary, use the drop-down menu now in the |
| 1394 | "Connection" field and pick the IP Address you |
| 1395 | entered. |
| 1396 | </para></listitem> |
| 1397 | <listitem><para> |
| 1398 | Assuming you are connecting as the root |
| 1399 | user, which is the default for QEMU x86-64 SDK |
| 1400 | images provided by the Yocto Project, in the |
| 1401 | "Remote Absolute File Path for C/C++ Application" |
| 1402 | field, browse to |
| 1403 | <filename>/home/root/</filename><replaceable>ProjectName</replaceable> |
| 1404 | (e.g. <filename>/home/root/hello</filename>). |
| 1405 | You could also browse to any other path you have |
| 1406 | write access to on the target such as |
| 1407 | <filename>/usr/bin</filename>. |
| 1408 | This location is where your application will be |
| 1409 | located on the QEMU system. |
| 1410 | If you fail to browse to and specify an appropriate |
| 1411 | location, QEMU will not understand what to remotely |
| 1412 | launch. |
| 1413 | Eclipse is helpful in that it auto fills your |
| 1414 | application name for you assuming you browsed to a |
| 1415 | directory. |
| 1416 | <note> |
| 1417 | If you are prompted to provide a username and |
| 1418 | to optionally set a password, be sure you |
| 1419 | provide "root" as the username and you leave |
| 1420 | the password field blank. |
| 1421 | </note> |
| 1422 | </para></listitem> |
| 1423 | <listitem><para> |
| 1424 | Be sure you change to the "Debug" perspective in |
| 1425 | Eclipse. |
| 1426 | </para></listitem> |
| 1427 | <listitem><para> |
| 1428 | Click "Debug" |
| 1429 | </para></listitem> |
| 1430 | <listitem><para> |
| 1431 | Accept the debug perspective. |
| 1432 | </para></listitem> |
| 1433 | </orderedlist> |
| 1434 | </para> |
| 1435 | </section> |
| 1436 | |
| 1437 | <section id='neon-using-Linuxtools'> |
| 1438 | <title>Using Linuxtools</title> |
| 1439 | |
| 1440 | <para> |
| 1441 | As mentioned earlier in the manual, performance tools exist |
| 1442 | (Linuxtools) that enhance your development experience. |
| 1443 | These tools are aids in developing and debugging |
| 1444 | applications and images. |
| 1445 | You can run these tools from within the Eclipse IDE through |
| 1446 | the "Linuxtools" menu. |
| 1447 | </para> |
| 1448 | |
| 1449 | <para> |
| 1450 | For information on how to configure and use these tools, |
| 1451 | see |
| 1452 | <ulink url='http://www.eclipse.org/linuxtools/'>http://www.eclipse.org/linuxtools/</ulink>. |
| 1453 | </para> |
| 1454 | </section> |
| 1455 | </section> |
| 1456 | </section> |
| 1457 | </chapter> |
| 1458 | <!-- |
| 1459 | vim: expandtab tw=80 ts=4 |
| 1460 | --> |