Search by Tags
  • Computer on Module
    Apalis iMX6 Dual/Quad
  • Carrier Board
    Apalis Evaluation Board
  • Computer on Module OS
    Linux
  • Development PC OS
    Linux

Configure Eclipse

 
 

Attention: the Quickstart Guide for BSP 2.8, based on the Ångström distribution, is not being updated anymore. Depending on your SoM, you have different options:

Vybrid and Tegra: the information is provided as-is and still accurate, since newer Toradex BSPs are not ported to those SoMs. Just keep in mind that the Guides are not being maintained anymore, even if we find bugs or outdated instructions.

Apalis TK1 (all variants), Colibri iMX6ULL (all variants), Colibri iMX7S 256MB and Colibri iMX7D 512MB: these computer on modules are still regularly maintained in our BSPs and, to get started, you must check the software page Toradex BSP Layers and Reference Images for Yocto Project. Since Torizon is not supported, at the moment a Quickstart Guide is not available.

All other i.MX-based SoMs: you have two options to get started with embedded Linux: the first is to follow the Quickstart Guide for Torizon, which provides the greatest out-of-the-box experience, or if you choose to use Yocto, check the software page Toradex BSP Layers and Reference Images for Yocto Project.

Overview

In this section, you will configure the Eclipse IDE for cross-compilation and learn how to use it to deploy your application to the target.

Information provided in this section was based on the Linux SDKs and the Hello World application on Embedded Linux articles from Toradex' knowledge-base. Notice that even though the latter uses the Linaro toolchain, the concepts presented can be applied when using the OpenEmbedded SDK as well.

In this module you will:

  • Download and install the latest Eclipse IDE for C/C++ developers
  • Configure a C project for cross-compilation using the provided Software Development Kit (SDK)
  • Cross-compile a hello-world application

Note: This guide provides information for the Eclipse Neon 3 release. Other releases than Neon may require extra steps to be followed which are not covered in this guide.

Prerequisites

  • Host computer running the regular 64-bit installation of Ubuntu 16.04 LTS, as stated in the module 1 cover page.

Note: On versions newer than Ubuntu 16.04 LTS, you must choose to either replace Java 11 by Java 8 or use a newer version of Eclipse.

Step 1

Go to the Eclipse Neon 3 packages page and download the Eclipse IDE for C/C++ developers:



  • Download Eclipse Neon IDE for C/C++ developers

    Download Eclipse Neon IDE for C/C++ developers

For illustration purposes, consider that Eclipse is downloaded to ~/Downloads.

Step 2

Make sure you have Java installed before proceeding:

sudo apt-get update
sudo apt-get install default-jre

Note: this lesson has been written for Ubuntu 16.04 LTS, as stated in the module 1 cover page. On versions newer than Ubuntu 16.04 LTS, you must choose to either replace Java 11 by Java 8 or use a newer version of Eclipse.

Here is an example how to install Java 8:

sudo apt-get install openjdk-8-jre
sudo update-alternatives --config java

Step 3

Create a directory for Eclipse installations and extract the contents of the downloaded file:

cd ~
mkdir -p ~/eclipse/neon-3
tar xf ~/Downloads/eclipse-cpp-neon-3-linux-gtk-x86_64.tar.gz -C ~/eclipse/neon-3/

Note: Using this directory structure, you can install other versions of Eclipse for testing in the same directory, for instance at ~/eclipse/latest/

You can check that it went as expected by verifying the directory structure:

user@host:~$ ls ~/eclipse/neon-3/
eclipse
user@host:~$ ls ~/eclipse/neon-3/eclipse/
artifacts.xml configuration dropins eclipse eclipse.ini features icon.xpm notice.html p2 plugins readme

Step 4

Go to the Eclipse installation folder created in the previous step:

cd ~/eclipse/neon-3/eclipse

Attention: If you close Eclipse and the terminal, you need to export the variables again before starting Eclipse.

  • Export the Toradex SDK variables and run eclipse:
. /usr/local/oecore-x86_64/environment-setup-armv7at2hf-neon-angstrom-linux-gnueabi
./eclipse

Warning: In the first command above, notice that there are a dot and space before the path to the script.

Step 5

You will be asked to choose a workspace to keep your projects and configurations:



  • Default workspace

    Default workspace

Step 6

In the welcome page, select:

  • Create a new C project



  • Default workspace

    Default workspace

Step 7

Give a name to the project. Select:

  • Project type as Executable --> Hello World ANSI C Project
  • Toolchain as Cross GCC



  • Project setup part 1

    Project setup part 1

Step 8

Type your name and proceed:



  • Project setup part 2

    Project setup part 2

Step 9

Select the debug and release configurations and click the next button:



  • Project setup part 3

    Project setup part 3

Step 10

Leave the cross-compiler prefix and path empty:



  • Project setup part 4

    Project setup part 4

Click the finish button.

Step 11

In the toolbar, click Project and select Properties from the drop down menu:


  • Project Properties

    Project Properties

Step 12

Go to the tab:

  • C/C++ Build --> Settings

Choose the option:

  • Cross GCC Compiler

From the Configuration dropdown menu:

  • Select [ All configurations ]

In the Command field, replace the contents with the Cross Compiler variable "${CC}", as presented below:

${CC}

See the image for reference:



  • Setting the Command variable

    Setting the Command variable

Step 13

Go to the tab:

  • C/C++ Build --> Settings

Choose the option:

  • Cross GCC Compiler --> Miscellaneous

From the Configuration dropdown menu:

  • Select [ All configurations ]

In the Other flags field, replace the contents with the variable "${CFLAGS} -c", as presented below:

${CFLAGS} -c

See the image for reference:



  • Setting the Other Flags to use variable from Cross Compiler Enviroment

    Setting the Other Flags to use variable from Cross Compiler Enviroment

Note: The current level of compiler optimization set in CFLAGS (-O2) might impair debug to some extent. If you have trouble debugging applications of your own, you may try substituting '${CFLAGS} -c' to '-Og -pipe -g -feliminate-unused-debug-types -c'

Step 14

Go to the tab:

  • C/C++ Build --> Settings

Choose the option:

  • Cross GCC Linker

From the Configuration dropdown menu:

  • Select [ All configurations ]

In the Command field, replace the content with the Cross Compiler variable "${CXX}", as presented below:

${CXX}

See the image for reference:



  • Setting the Command variable

    Setting the Command variable

Step 15

Go to the tab:

  • C/C++ Build --> Settings

Choose the option:

  • Cross GCC Linker --> Miscellaneous

From the Configuration dropdown menu:

  • Select [ All configurations ]

In the Linker flags field, replace the content with the variable "${LDFLAGS}", as presented below:

${LDFLAGS}

See the image for reference:



  • Setting the Other Flags to use variable from Cross Linker Enviroment

    Setting the Other Flags to use variable from Cross Linker Enviroment

Step 16

Go to the tab:

  • C/C++ Build --> Settings

Choose the option:

  • Cross GCC Assembler

From the Configuration dropdown menu:

  • Select [ All configurations ]

In the Command field, replace the content with the Cross Compiler variable "${AS}", as presented below:

${AS}

See the image for reference:



  • Setting the Command variable

    Setting the Command variable

After you are done:

  • Click the OK button

You will return to the previous menu:

  • Click next to proceed

Step 17

Press Ctrl+B or click the build all button to build the project. A build log will tell if you succeeded:



  • Build button and log

    Build button and log

FAQ

This lesson covers the basics of Eclipse IDE configuration, therefore this FAQ section is meant as an information complement.

How can I debug my application using Eclipse
How can I set or modify the default value of the SDK variables
How can I directly set the compiler flags in the Eclipse IDE
Where can I find more information about the Eclipse IDE
Which version of the Eclipse IDE should I use
Are there alternatives to the Eclipse IDE