Creating A New Eclipse Project

Eclipse uses workspaces, which is simply a folder where you have one or more projects. You can switch workspace to a new workspace so if you want to you can simply start with a workspace that has a single project and change to a new workspace when you want to work on a different project.  Workspaces can use long paths and have space characters in names etc (no funny restrictions we've come across)

Create A Project

Follow this to create a blank project – if you have existing files to add leave doing that until you have completed all of the steps.

Open Eclipse (Right click the eclipse.exe in the C:\eclipse folder and run as administrator).  For the workspace prompt select the directory where you will be creating your project, e.g. "C:\My Project\firm\V1-00"

File > New > C++ Project

Give the project a name

Hello World C++ Project

Cross GCC

Everything else as default.

Right click the project in Project Explorer > Properties

You should see the new project IDE.  If not make sure this button is pressed:

eclipse_show_project_button

Configure it as follows, by right clicking the project name in the Project Explorer and selecting properties:
C/C++ Build > Environment

  • Add a variable named CYGWIN with value nodosfilewarning (tick 'add to all configurations')
  • Append the following to the beginning of the PATH variable: c:\cygwin\opt\cross\x-tools\arm-unknown-linux-gnueabi\bin;c:\cygwin\bin;

C/C++ Build > Tool Chain Editor

  • Select Cygwin GCC from Current toolchain dropbox.

C/C++ Build > Settings > Tool Settings

  • Set the Command field in Cygwin C++ Compiler to: arm-unknown-linux-gnueabi-g++
  • Add an include path (not include files) in Includes which points to: c:\cygwin\opt\cross\x-tools\arm-unknown-linux-gnueabi\arm-unknown-linux-gnueabi\sysroot\usr\include
  • Set the Command field in Cygwin C Compiler to: arm-unknown-linux-gnueabi-g++
  • Add an include path (not include files) in Includes which points to: c:\cygwin\opt\cross\x-tools\arm-unknown-linux-gnueabi\arm-unknown-linux-gnueabi\sysroot\usr\include
  • Set the Command field in Cygwin C++ Linker to: arm-unknown-linux-gnueabi-g++
  • Add a library search path (not Libraries) in Libraries which points to: c:\cygwin\opt\cross\x-tools\arm-unknown-linux-gnueabi\arm-unknown-linux-gnueabi\sysroot\usr\lib

C/C++ Build > Settings > Build Steps

  • Set the Command field in Post-build steps to: C:/eclipse/deployment_scripts/rpi_deploy_debug.bat $(OutDir)${ProjName}.a "/home/pi/projects/${ProjName}.a"
  • Add the description field to: Our auto deploy to RPi using putty script

C/C++ Build > Settings > Build Artifact

  • Set Artifact Extension to: a

Press OK

Compiling

(Tested with Eclipse V4.2 Juno)
Project > Build All (or Project > Build Project if "Build All" is not available)

The project should compile without errors at this point.

Problems
  • If the PuTTY window hangs just close it and confirm the close session box if it asks if you are sure.  This is not a problem and putty remains working in the background.
  • Trying running eclipse by right clicking eclipse.exe and selecting 'Run as administrator'.
  • If you get /usr/bin/sh: g++: command not found errors you can right click the project > Properties > C/C++ Build > Discovery Options and turn off 'Automate discovery of paths and symbols for both of the Cygwin tools listed.  However this shouldn't be necessary.
  • If you get other errors then go through and check the previous steps have been followed precisely.
  • Opening workspace project not shown – you may need to press this button to see the project:
    eclipse_show_project_button
  • Eclipse can be buggy. Try restarting it, or closing it then creating a new project to see if the problem magically vanishes (it sometimes does!).

If everything went smoothly select the Console output view in Eclipse and it should have printed something about the binary uploading and command execution.

Problems

Delete the file on the RPi and then re-build

Hangs with PuTTY window open – just close it (it still runs in the background)

Debugging With Eclipse

The following is a re-workign of our original non working instructions following the solution found by ChristianM – thanks Christian!

Creating A Remote Connection

If you've not proviously created a remote connection called remote_rpi (you can look in Menu > Window > Show View > Other > Remote Systems > Remote Systems) then create one first:

Menu > File > New > Other > Remote System Explorer > Connection
SSH Only
Host name: The IP address of the RPi
Connection name: remote_rpi
Rest default (just press finish)

Setup Debugging

Now setup a Debug Configuration.
Select Menu Run > Debug configurations from the top menu.
Right click on C/C++ Remote Application and choose New to add a new configuration.

Main tab

  • Set  "C/C++ Application field" to the name of the produced binary: Debug/${project_name}.a
  • Select Disable auto build.
  • Click on Select other…, near the left of the Apply button. From the newly opened window, choose GDB (DSF) Automatic Remote Debugging Launcher and click ok.
  • Remote Absolute File Path for C/C++ Application: Set to the path where the application will be running on the Raspberry, e.g. /home/pi/projects/my_project.a    (you can't use ${ProjName} or ${project_name} here)
  • "Connection:" drop down box: Select the "remote_rpi" connection you made.

Debugger tab

  • Set the GDB debugger field to the path of the gdb which is part of our downloaded tool chain, so: c:\cygwin\opt\cross\x-tools\arm-unknown-linux-gnueabi\bin\arm-unknown-linux-gnueabi-gdb.exe

Source tab

  • Add > Path mapping.
  • Name it "Cygwin C Drive" and in Compilation Path enter: /cygdrive/c/
  • In Local file system path enter: C:\

Click on Apply and then Close. 

 

To leave the debug perspective (mode) use Window > Open Perspective > C/C++
To come back use Window > Open Perspective > Debug
 

To Debug your project select "Debug" from the Menu > Run > Debug Configurations, or Menu > Run > Debug Histroy > rpi Debug

Problems

Delete the file on the RPi and then re-build

Setup Required On The Raspberry Pi

In the "C/C++ Build > Settings > Build Steps" step above the target for the putty transfer is set to "/home/pi/projects/${ProjName}.a".  You need to create this /projects/ directory on the RPi for the project .a file to be transferred into, so use this at the RPi command line:

mkdir projects

To run it see here.

Eclipse Settings

Save files before build needs turning on:

Window > Preferences > General > Workspace.  Check 'Save automatically before build'.

Adding The IO Library To Eclipse

See here

 

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

  1. Bob W

    1 year ago

    Have updates for the newer version of eclipse and updated build tool chain. btw, cygwin may not be necessary.

    Eclipse:
    Version: 2022-12 (4.26.0)
    Build id: 20221201-1913

    ARM Build Tools cross development tools
    SysGCC

  2. Linus S

    9 years ago

    I had to manually configure the preprocessor include paths to use those provided by cygwin, it was trying to use the CDT Cross GCC Built-in Compiler Settings thus giving me warnings about non-existent include paths (such as ‘/usr/include’) so I unticked the Cross GCC and used the CDT GCC Built-in Compiler Settings Cygwin instead (by going to C/C++ General > Preprocessor Include Paths… > Providers). Now I didn’t get any warnings or errors.

  3. Quentin Lohri

    3 years ago

    Hi,

    When I compile, finished build target is ok!
    But I’ve a problem with post-build.
    Problem:

    /usr/bin/make –no-print-directory post-build
    upload and debug
    C:/Raspi Studio/deploy_debug.bat/helloRaspi.a “/home/pi/projects/helloRaspi.a”
    /bin/sh: C:/Raspi: No such file or directory
    makefile:43: recipe for target ‘post-build’ failed
    make[1]: [post-build] Error 127 (ignored)

    Idea? It’s 2 day I look for this :(

Comments

Your email address will not be published. Required fields are marked *