nurquhar
Posts: 16
Joined: Thu May 10, 2012 7:11 pm
Contact: Website

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Tue Jan 08, 2013 3:26 pm

The approch I have taken is to setup the simple "Hello World" project in a test workspace with all the paths configured etc. Then I have another workspace for development. To start a new project I use the "import" from the project explorer tab and copy in the "Hello World" project using the General/Existing Projects into Workspace option. Make sure you click the "copy projects into workspace" option. Then use "rename".

ZArie
Posts: 5
Joined: Sat Aug 04, 2012 11:15 am

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Tue Jan 08, 2013 9:23 pm

Thanks nurquhar !
I still was struggling on getting things working and in one of the "tests" I took the approach of macca, of defining the project as "Cross GCC" (no need to define include directories - beside the initial steps as macca clearly described), and it works like a charm !

I am now looking on how to do the remote debugging from Ubuntu to the Raspberry using gdb.

nurquhar
Posts: 16
Joined: Thu May 10, 2012 7:11 pm
Contact: Website

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Wed Jan 09, 2013 11:18 am

Dear ZArie

The Cross option worked for me, this seems to the better soloution than all those path entries.

I would be interested in how you get on with Ubuntu -> RPi eclipse debug setup. I have wasted quite an amount of time on it so far without much success.

I have just tired bypassing eclipse for the moment and to see if I can understand how to make it work from the command line. I managed to set a break point at "main" and execute "hello world" on the RPi. See output from host and client as below.

Code: Select all

nurquhar@KubuntuVM:~/workspace/ArmCrossCpp/Debug$ file ArmCrossCpp
ArmCrossCpp: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x7402abd6c6edd6bd3ec33dce4b002e0e4be2b7ea, not stripped
nurquhar@KubuntuVM:~/workspace/ArmCrossCpp/Debug$ scp ArmCrossCpp pi@raspberrypi:tmp
pi@raspberrypi's password: 
ArmCrossCpp                                                                                 100%   62KB  61.5KB/s   00:00    
nurquhar@KubuntuVM:~/workspace/ArmCrossCpp/Debug$ arm-linux-gnueabihf-gdb ArmCrossCpp
GNU gdb (crosstool-NG linaro-1.13.1+bzr2458 - Linaro GCC 2012.08) 7.4-2012.06
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-build_pc-linux-gnu --target=arm-linux-gnueabihf".
For bug reporting instructions, please see:
<https://bugs.launchpad.net/gcc-linaro>...
Reading symbols from /home/nurquhar/workspace/ArmCrossCpp/Debug/ArmCrossCpp...done.
(gdb) target remote raspberrypi:2345
Remote debugging using raspberrypi:2345
Reading symbols from /home/nurquhar/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3...(no debugging symbols found)...done.
Loaded symbols for /home/nurquhar/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3
0x40000ef0 in ?? ()
   from /home/nurquhar/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3
(gdb) list
Cannot access memory at address 0x0
4       // Version     :
5       // Copyright   : Your copyright notice
6       // Description : Hello World in C++, Ansi-style
7       //============================================================================
8
9       #include <iostream>
10      using namespace std;
11
12      int main() {
13              cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
(gdb) b main
Breakpoint 1 at 0x8738: file ../src/ArmCrossCpp.cpp, line 13.
(gdb) continue
Continuing.

Breakpoint 1, main () at ../src/ArmCrossCpp.cpp:13
13              cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
(gdb) continue
Continuing.
[Inferior 1 (process 3773) exited normally]
(gdb)

Code: Select all

pi@raspberrypi ~/tmp $ file ArmCrossCpp
ArmCrossCpp: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x7402abd6c6edd6bd3ec33dce4b002e0e4be2b7ea, not stripped
pi@raspberrypi ~/tmp $ gdbserver :2345 ArmCrossCpp
Process ArmCrossCpp created; pid = 3773
Listening on port 2345
Remote debugging from host 192.168.1.118
!!!Hello World!!!

Child exited with status 0
GDBserver exiting
pi@raspberrypi ~/tmp $ 
Problem is , can this be made to work from within eclipse ?

ZArie
Posts: 5
Joined: Sat Aug 04, 2012 11:15 am

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Wed Jan 09, 2013 12:59 pm

Dear nurquhar,
I was searching the web and found a good tutor on how to have Eclipse Cross debug,
http://linuxtortures.blogspot.co.il/201 ... ing-c.html
I followed my missing part that relates to the Cross debug and it works just fine.
The page is very easy to follow and detailed.
BR,
Arie

nurquhar
Posts: 16
Joined: Thu May 10, 2012 7:11 pm
Contact: Website

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Wed Jan 09, 2013 2:33 pm

Dear ZArie

I have used the last part of the tutorial to start the debugger using "Manual" start of gdbserver. This seems to work. I had been using "Automatic" which I thought should cause eclipse to use ssh to start the gdbserver on the pi. I guess this must be broken.

What I did notice about the setup in the tutorial you referenced is that I had to configure the gdb debugger as "arm-linux-gnueabihf-gdb" and not "arm-linux-gnueabi-gdb" !

Having now looked at the first half of the tutorial I see the means of installing the cross compiler is somewhat different to the "hertaville" method which I have used. ie I used this :
sudo apt-get install git
sudo git clone git://github.com/raspberrypi/tools.git

instead of the long of list of sudo stuff.

Will I be missing some essential libraries ? Do I have a different setup as all my tools are "arm-linux-gnueabihf-???" instead of "arm-linux-gnueabi-???"

I think the "hf" bit means hard-float. Presumable there are two types of "float" support, ie hardware and software formated numbers. Which is correct for the Pi and why ? Does the Pi have a "maths co-processor" which forces the format of floats to compatible with it hardware ?

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Wed Jan 09, 2013 4:31 pm

nurquhar wrote:I think the "hf" bit means hard-float. Presumable there are two types of "float" support, ie hardware and software formated numbers. Which is correct for the Pi and why ? Does the Pi have a "maths co-processor" which forces the format of floats to compatible with it hardware ?
I would assume this depends on what operating system version you run on your RPi - most by now are hard-float, but not all - you should match the tools with the underlying OS...
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

halhertani
Posts: 40
Joined: Sun Aug 19, 2012 5:02 am
Location: Ottawa, ON Canada
Contact: Website

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Sat Jan 12, 2013 3:31 am

A remote debugging tutorial is finally up!
http://hertaville.com/2013/01/11/remote-debugging/

This is a continuation of the "Development Environment for the Raspberry Pi using a Cross Compiling Toolchain and Eclipse" http://hertaville.com/2012/09/28/develo ... -compiler/, Which covers how one can build raspberryPi applications on a Linux PC/VM using a cross compiling toolchain and eclipse

The second tutorial (first URL link) continues where the first one left off. It demonstrates how one can remotely debug Raspberry Pi applications on the Raspberry Pi from an Eclipse setup running on a Linux PC/VM.

I hope that you find it useful!!!

ZArie
Posts: 5
Joined: Sat Aug 04, 2012 11:15 am

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Sat Jan 12, 2013 1:17 pm

halhertani !
This is great ! the Automatic GDB.
I encountered a small difficulty that I had to change.
In the Main tab (of C/C++ Remote Application), after defining the connection, need to make sure that the "Remote Absolute File Path for C/C++ Application" is pointing to an existing path on the remote/target raspi; which late on in the "Command to execute before application" it is required to "chmod +x ..." it.
For me beside of that is works just great !
Thanks,
Arie

halhertani
Posts: 40
Joined: Sun Aug 19, 2012 5:02 am
Location: Ottawa, ON Canada
Contact: Website

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Sun Jan 13, 2013 6:53 pm

Zarie,
I'm glad that you were able to find the remote debugging tutorial useful! Writing it got delayed because I was spending quite a bit of time learning about Linux systems programming. I will try to make some of the instructions a little clearer.

msmithy12
Posts: 94
Joined: Fri Aug 10, 2012 8:57 am

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Tue Jan 22, 2013 1:49 pm

Ok, so im successfully cross compiling. 2 questions

Can i save the raspberry pi settings in eclipse so i don`t have to add the includes/library paths every time i want to start a new program?

Can i use the wiringPi headers in eclipse?
I assume I know what I`m talking about... I probably don`t

Home: 256mb Made in UK, Rasbmc, 40" Sony Bravia KDL-40v3000
Work: 2b+, Rasbian, 6" Lilliput touchscreen

sej7278
Posts: 249
Joined: Tue Jan 22, 2013 6:43 pm

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Thu Jan 24, 2013 1:07 am

why are you using sudo all the time when you're only writing to your own files in your $HOME directory? am i missing something there, or are you too used to ubuntu :lol:

also why are you using linaro instead of bcm2708hardfp - i didn't think linaro was actually any faster on armv6 (makes a difference on armv7) so surely the toolchain specific to our chip would be better - it seems raspbian is using "arm-linux-gnueabihf" gcc 3.5

personally i found its enough to git clone the toolchain, then set your $PATH to include ~/raspberrypi/tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin or wherever you download it to, then to compile something you just run:

Code: Select all

arm-bcm2708hardfp-linux-gnueabi-gcc -o helloworld helloworld.c
or if you have a Makefile and configure program to run:

Code: Select all

./configure --host=arm-bcm2708hardfp-linux-gnueabi && make

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 27452
Joined: Sat Jul 30, 2011 7:41 pm

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Thu Jan 24, 2013 10:10 am

On instruction from Dom, I've been using the Linaro toolchain for cross compiling. Not sure why that's the recommended one though - I'll ask.

James
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

sej7278
Posts: 249
Joined: Tue Jan 22, 2013 6:43 pm

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Thu Jan 24, 2013 1:20 pm

jamesh wrote:On instruction from Dom, I've been using the Linaro toolchain for cross compiling. Not sure why that's the recommended one though - I'll ask.
Thanks

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 27452
Joined: Sat Jul 30, 2011 7:41 pm

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Thu Jan 24, 2013 1:59 pm

sej7278 wrote:
jamesh wrote:On instruction from Dom, I've been using the Linaro toolchain for cross compiling. Not sure why that's the recommended one though - I'll ask.
Thanks
It appears Linaro produces slightly better code (certainly according to nbench), which is why we are using it here.

James
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

halhertani
Posts: 40
Joined: Sun Aug 19, 2012 5:02 am
Location: Ottawa, ON Canada
Contact: Website

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Fri Jan 25, 2013 8:15 pm

msmithy12 wrote:Ok, so im successfully cross compiling. 2 questions

Can i save the raspberry pi settings in eclipse so i don`t have to add the includes/library paths every time i want to start a new program?

Can i use the wiringPi headers in eclipse?


msmithy,
You can create a generic project with all the settings adjusted and make copies of it whenever you need a new project. Alternatively you can use the cross GCC (see Fig 6) option instead of the linux gcc option. This along with a minor project setting adjustment (see Macca's instructions posted earlier on, in this thread) should make setting up the project easier.

As for the wiringPi header I do not see why not, as long as the wiringPi library is compiled by the cross-compiler . You may want to include the wiringPi source code into your project to compile it from source along with your project. You may also create (again using rhe cross compiler) a wiringPi static library that can be linked to your project.

halhertani
Posts: 40
Joined: Sun Aug 19, 2012 5:02 am
Location: Ottawa, ON Canada
Contact: Website

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Fri Jan 25, 2013 8:30 pm

sej7278 wrote:why are you using sudo all the time when you're only writing to your own files in your $HOME directory? am i missing something there, or are you too used to ubuntu :lol:

also why are you using linaro instead of bcm2708hardfp - i didn't think linaro was actually any faster on armv6 (makes a difference on armv7) so surely the toolchain specific to our chip would be better - it seems raspbian is using "arm-linux-gnueabihf" gcc 3.5

personally i found its enough to git clone the toolchain, then set your $PATH to include ~/raspberrypi/tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin or wherever you download it to, then to compile something you just run:

Code: Select all

arm-bcm2708hardfp-linux-gnueabi-gcc -o helloworld helloworld.c
or if you have a Makefile and configure program to run:

Code: Select all

./configure --host=arm-bcm2708hardfp-linux-gnueabi && make
sej7278,
You are correct. There are a few places where i used sudo when i didn't need to. I've since been paying a closer look at Linux and hopefully know a bit more. I'm currently using Debian Wheezy and really like it.

Most Linux beginners prefer Ubuntu/Linux Mint, But I'm not a big fan of either,especially Ubuntu which is becoming more bloated(Unity, app store e.t.c) with every release. Kubuntu seemed like a reasonably easy Distro to use(similar to Ubuntu) but not as bloated.

I don't consider myself to be a Linux Guru by any stretch of the imagination....more of a Linux explorer. When I tried adding the toolchains directory to the PATH in either the .bashrc or .profile file, Eclipse was unable to to detect the toolchain. When modifying the PATH variable in both files however it worked....still trying to understand why.

Finally the linaro toolchain was the latest (hf) addition to the tools git repository and I heard that it was a better toolchain to use. Alternatively one can create his/her own toolchain using the crosstool-ng scripts.

Frankly I find myself now mostly using VIM for editing, and invoke the toolchain from command line

casmer
Posts: 3
Joined: Sun Jan 26, 2014 10:13 pm

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Sun Jan 26, 2014 10:15 pm

halhertani wrote:I've recently posted a tutorial on how to setup a Development environment on a Linux box/virtual machine that utilizes Eclipse and the cross Compiling toolchain (official one posted on github) to develop code for the Raspberry Pi.

http://hertaville.com/2012/09/28/develo ... -compiler/

I hope others find it useful. All feedback is welcome
I have os x and i am wondering if i can run this compiler without installing a linux vm. its more convenient to not run a vm.

zeolit
Posts: 1
Joined: Sun Feb 02, 2014 4:58 pm

Re: GNU C/C++ Cross Compiler + Eclipse Development Environme

Sun Feb 02, 2014 5:02 pm

Can anyone help me with cross compiler always blocks , when i start typing...









----------------------------------------
Zeolit

Return to “C/C++”