kamac495
Posts: 34
Joined: Wed Sep 26, 2012 8:04 pm
Contact: Website

Writing for raspberry from PC?

Wed Feb 27, 2013 2:22 pm

Hi.

Is there any possibility to write programs for raspberry from PC?
I mean C++ here.

Just to clarify - I'd like to write code once, instead of doing changes on raspberry later on (If possible). And is it possible to compile from PC using GNU compiler for ARMv6 raspberry? (Instead of compiling the whole thing on raspberry itself)
My site
http://www.motionstruct.com

User avatar
joan
Posts: 15270
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Writing for raspberry from PC?

Wed Feb 27, 2013 2:27 pm

It should be.

I compile for soft float on a (Linux) PC. Google for raspberry pi cross-compiler. I think the tool-chain for cross-compiling hard float is harder to set up - but I haven't tried recently.

kamac495
Posts: 34
Joined: Wed Sep 26, 2012 8:04 pm
Contact: Website

Re: Writing for raspberry from PC?

Wed Feb 27, 2013 2:32 pm

The only problem is with creating a window I suppose.
On linux it's X11 I guess, while on pi it's something else.

That's the biggest pain.
My site
http://www.motionstruct.com

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

Re: Writing for raspberry from PC?

Wed Feb 27, 2013 2:41 pm

You can do X11 on RPi as well, but to avail of the hw acceleration you might want to avoid X... Then there is of course Qt and possibly some other portable UI libraries like Gtk...
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

User avatar
joan
Posts: 15270
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Writing for raspberry from PC?

Wed Feb 27, 2013 2:45 pm

kamac495 wrote:The only problem is with creating a window I suppose.
On linux it's X11 I guess, while on pi it's something else.

That's the biggest pain.
The Pi is (by default) a Linux machine and supports X. I'm not sure why that is a factor. Are you trying to provide a GUI which is portable between Windows and Linux?

kamac495
Posts: 34
Joined: Wed Sep 26, 2012 8:04 pm
Contact: Website

Re: Writing for raspberry from PC?

Wed Feb 27, 2013 3:03 pm

I'd actually like to create application non-dependant on X (running fullscreen always). I've got small if not zero experience with coding for Linux, so I am not sure whether I can code such application on Ubuntu (my alt-OS).
My site
http://www.motionstruct.com

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

Re: Writing for raspberry from PC?

Wed Feb 27, 2013 3:26 pm

kamac495 wrote:I'd actually like to create application non-dependant on X (running fullscreen always). I've got small if not zero experience with coding for Linux, so I am not sure whether I can code such application on Ubuntu (my alt-OS).
Alternatively you can do compiles on the PC (very fast) and run then result on the Raspi. That's what I do - I run Eclipse on an Ubuntu PC, cross compile using the tools on github, then debug/run on the Raspi itself (I also have the debugger running on the PC debugging remotely to the Raspi).
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.

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

Re: Writing for raspberry from PC?

Wed Feb 27, 2013 4:02 pm

kamac495 wrote:I'd actually like to create application non-dependant on X (running fullscreen always). I've got small if not zero experience with coding for Linux, so I am not sure whether I can code such application on Ubuntu (my alt-OS).
It's still a bit unclear whether you want to:
A) run the same application on both RPi and your 'Ubuntu PC', which would require a cross-platform library (Gtk, Qt, ... I wonder if EGL is available on Ubuntu, and if you don't need hw acceleration there is always the framebuffer that is common in both envs...) and most likely cross-compilation for RPi
or
B) code on Ubuntu and run on Rpi, which would be the job for the cross-compiling option jamesh mentioned - using only RPi specific libraries
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

kamac495
Posts: 34
Joined: Wed Sep 26, 2012 8:04 pm
Contact: Website

Re: Writing for raspberry from PC?

Wed Feb 27, 2013 4:04 pm

According to what has been said, this:
B) code on Ubuntu and run on Rpi, which would be the job for the cross-compiling option jamesh mentioned - using only RPi specific libraries
Seems as to be the best option for me.
My site
http://www.motionstruct.com

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

Re: Writing for raspberry from PC?

Wed Feb 27, 2013 4:24 pm

I suppose it is this then: "GNU C/C++ Cross Compiler + Eclipse Development Environment" http://www.raspberrypi.org/phpBB3/viewt ... 33&t=18721
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

kamac495
Posts: 34
Joined: Wed Sep 26, 2012 8:04 pm
Contact: Website

Re: Writing for raspberry from PC?

Wed Feb 27, 2013 7:24 pm

I've got small problems with that tutorial, namely I am using Ubuntu and can't install ia32-libs (since as I read, they're deprecated).
I did:
sudo dpkg --add-architecture i386
sudo apt-get update

But yet when I try to run this: arm-linux-gnueabihf-gcc -v
It tells me that file has not been found. (I checked, path is proper and the file is there)

Any tips? Help?
My site
http://www.motionstruct.com

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

Re: Writing for raspberry from PC?

Thu Feb 28, 2013 11:22 am

Sorry, cannot help you there. Maybe post your problem into the cross-compiling thread? Might get more experienced views...
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

Gustavo_Murta
Posts: 24
Joined: Thu Dec 20, 2012 10:04 am
Location: Brasil

Re: Writing for raspberry from PC?

Thu Feb 28, 2013 11:51 am

Try to use PI emulator in your PC.
I think you can compile C in the Pi emulator window, with some limitations.

http://xecdesign.com/qemu-emulating-ras ... -easy-way/

Gustavo Murta

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

Re: Writing for raspberry from PC?

Thu Feb 28, 2013 2:02 pm

kamac495 wrote:I've got small problems with that tutorial, namely I am using Ubuntu and can't install ia32-libs (since as I read, they're deprecated).
I did:
sudo dpkg --add-architecture i386
sudo apt-get update

But yet when I try to run this: arm-linux-gnueabihf-gcc -v
It tells me that file has not been found. (I checked, path is proper and the file is there)

Any tips? Help?
If using a Linux box (e.g. Ubuntu) grab the Raspberry Pi tool chain (compilers etc) and userland code from here...

https://github.com/raspberrypi

Set up the Eclipse cross compile env to point to the tools (use Linaro tools from the three sets provided - they produce slightly faster code).

In cross settings (project properties, you need to set it up as a cross compile project),
Prefix: arm-linux-gnuabihf-
Path : <whatever you path to tools is>/arm-bcm2708/gcc-linaro-arm-linux-gnuabihf-raspbian

Set up include, libraries etc to point to their location in userland (you will need to run buildme at root of userland to build the libaries)

e,g, One include path might be...

arm-bcm2708/gcc-linaro-arm-linux-gnuabihf-raspbian/arm-linux-gnuabihf/libc/usr/include

There will be more requried (esp. if you need stuff from userland)

That should mostly cover it. I'm going to try and find time to write this stuff up in more detail.
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.

Return to “General programming discussion”