Search by Tags

Configure Eclipse

 
 

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.

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

Step 1

Go to the Eclipse packages page and download the Eclipse installer (or the Eclipse IDE for C/C++ developers. We will use the installer):



  • Download Eclipse Installer

    Download Eclipse Installer

Step 2

Make sure you have Java installed before proceeding:

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

Extract the contents of the downloaded file and start the Eclipse installer. You will see a window such as the presented below. Select the Eclipse IDE for C/C++ Developers, as highlighted:



  • Available Eclipse IDEs - select the C/C++ IDE

    Available Eclipse IDEs - select the C/C++ IDE

Step 3

Choose the installation folder and click the install button.

Attention: Remember the installation folder path. It will be required later.



  • Installation setup

    Installation setup

Step 4

Accept the license:



  • License agreement

    License agreement

Step 5

A progress bar will display the installation status:



  • Installation in progress

    Installation in progress

Step 6

Before finishing the installation, you will be prompted regarding some Eclipse certificates. Select all and click ok:



  • Eclipse trusted certificates

    Eclipse trusted certificates

Step 7

Close the installation. Do not launch the Eclipse IDE for C/C++ Developers:



  • Start the Eclipse IDE

    Start the Eclipse IDE

Instead of clicking the launch button, open a new terminal and:

  • Go to the Eclipse installation folder. By default, for the Eclipse Neon, it is a directory named cpp-neon/eclipse under the home folder. E.g.: ~/cpp-neon/eclipse
cd ~/cpp-neon/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 is a dot and a space before the path to the script.

Step 8

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



  • Default workspace

    Default workspace

Step 9

In the welcome page, select:

  • Create a new C project



  • Default workspace

    Default workspace

Step 10

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 11

Type your name and proceed:



  • Project setup part 2

    Project setup part 2

Step 12

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



  • Project setup part 3

    Project setup part 3

Step 13

Leave the cross compiler prefix and path empty:



  • Project setup part 4

    Project setup part 4

Click the finish button.

Step 14

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


  • Project Properties

    Project Properties

Step 15

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 16

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 17

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 18

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 19

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 20

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