Compiling Programs for the Pi


12 posts
by Bioshox » Thu May 31, 2012 11:00 am
Hi Guys

Are there any tutorials on compiling programs to run on the Raspberry Pi that arn't already ARM?

Thanks
Owner of: http://www.fusionstrike.com - I make gorgeous Raspberry Pi Tutorials :)
Posts: 100
Joined: Sun May 27, 2012 12:18 pm
Location: Manchester, United Kingdom.
by AndrewS » Thu May 31, 2012 11:25 am
Most programs you compile "aren't ARM". Linux software is largely written in C or C++, which are (for the most part) architecture-independent languages. When you compile a program, the compiler (usually GCC) converts this high-level C code into low-level (binary) ARM code.
So most code doesn't need any "conversion" to ARM, just compile it and run :D
(on your regular PC, GCC will convert the same C code into binary x86 code)

However there are a few special cases in which code might be architecture-specific if it's very highly optimised or contains inline assembler. In these cases there's nothing you can "easily" do to compile it for ARM, you need to wait for somebody (probably the initial author) to create ARM-specific versions of these parts of the code. :ugeek:
User avatar
Posts: 2789
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by Bioshox » Thu May 31, 2012 4:28 pm
I am trying to compile this: http://www.df.lth.se/~pi/mongo_big_endian.html

Which is an ARM version of MongoDB, although when I am I'm getting this error:

Code: Select all
root@raspberrypi:~/mongo# scons
scons: Reading SConscript files ...
scons version: 2.0.0.final.0
python version: 2 6 6 'final' 0
warning: using ubuntu without xulrunner-dev.  we recommend installing it
Checking whether the C++ compiler worksyes
Checking for C library stdc++... yes
Checking for C++ header file pcrecpp.h... yes
Checking for C++ header file boost/filesystem/operations.hpp... no
can't find boost headers
Owner of: http://www.fusionstrike.com - I make gorgeous Raspberry Pi Tutorials :)
Posts: 100
Joined: Sun May 27, 2012 12:18 pm
Location: Manchester, United Kingdom.
by rurwin » Thu May 31, 2012 4:35 pm
I believe MongoDB is already available for the RaspPi (sudo apt-get install MongoDB). Is there some reason you want to compile it?

It looks like it's missing some dependencies. Try installing the dev package of "boost" whatever that is.
User avatar
Forum Moderator
Forum Moderator
Posts: 2901
Joined: Mon Jan 09, 2012 3:16 pm
by Narishma » Thu May 31, 2012 4:56 pm
rurwin wrote:It looks like it's missing some dependencies. Try installing the dev package of "boost" whatever that is.

Boost is a very popular C++ template library (or rather a collection of libraries). Most of what gets added into newer C++ revisions usually comes from Boost.
Posts: 151
Joined: Wed Nov 23, 2011 1:29 pm
by Bioshox » Thu May 31, 2012 7:46 pm
rurwin wrote:I believe MongoDB is already available for the RaspPi (sudo apt-get install MongoDB). Is there some reason you want to compile it?

It looks like it's missing some dependencies. Try installing the dev package of "boost" whatever that is.


Unfortunately it doesn't seem to be available as I get the error no package found

Code: Select all
Last login: Thu May 31 00:07:48 2012 from 192.168.2.11
root@raspberrypi:~# sudo apt-get install MongoDB
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package MongoDB
root@raspberrypi:~#
Owner of: http://www.fusionstrike.com - I make gorgeous Raspberry Pi Tutorials :)
Posts: 100
Joined: Sun May 27, 2012 12:18 pm
Location: Manchester, United Kingdom.
by AndrewS » Thu May 31, 2012 10:40 pm
According to http://packages.debian.org/squeeze/mongodb there's two problems:
1) the package name is all lower-case ;)
2) it's not available for armel :(

P.S. Looks like this is the boost package you're missing http://packages.debian.org/squeeze/libboost-dev
so: "sudo apt-get install libboost-dev"
User avatar
Posts: 2789
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by Bioshox » Thu May 31, 2012 10:47 pm
AndrewS wrote:According to http://packages.debian.org/squeeze/mongodb there's two problems:
1) the package name is all lower-case ;)
2) it's not available for armel :(

P.S. Looks like this is the boost package you're missing http://packages.debian.org/squeeze/libboost-dev
so: "sudo apt-get install libboost-dev"


I managed to get that working, but now I get the error:

Code: Select all
root@raspberrypi:~/mongo# scons
scons: Reading SConscript files ...
scons version: 2.0.0.final.0
python version: 2 6 6 'final' 0
warning: using ubuntu without xulrunner-dev.  we recommend installing it
Checking whether the C++ compiler worksyes
Checking for C library stdc++... yes
Checking for C++ header file pcrecpp.h... yes
Checking for C++ header file boost/filesystem/operations.hpp... yes
Checking for C library boost_system-mt... yes
Checking for C library boost_thread-mt... yes
Checking for C library boost_filesystem-mt... yes
Checking for C library boost_program_options-mt... yes
Checking for C++ header file execinfo.h... yes
Checking for C library pcrecpp... yes
Checking for C library pcre... yes
Checking for C library pcap... no
Checking for C library wpcap... no
Checking for C library mozjs... no
Checking for C library js... no
Checking for C library js_static... no
can't find or link against library ['mozjs', 'js', 'js_static'] in []
see config.log for more information
root@raspberrypi:~/mongo# mongo
Owner of: http://www.fusionstrike.com - I make gorgeous Raspberry Pi Tutorials :)
Posts: 100
Joined: Sun May 27, 2012 12:18 pm
Location: Manchester, United Kingdom.
by AndrewS » Thu May 31, 2012 11:18 pm
http://packages.debian.org/squeeze/libmozjs-dev
You see that handy "Search" button on that page? :roll:
User avatar
Posts: 2789
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by usbspyder » Sat Jun 02, 2012 3:35 pm
I managed to get my favourite toy program, xswarm, running with the following. A dump of my command history follows.

Amazed that an old program (1990) still compiles and works for X11 out of the box, and it is such a short program.

Did require a lot of packages added to support the compile of X11 programs.

I'm using Debian squeeze, debian6-19-04-2012

From Windows I'm using xming for an X display with putty for normal ssh use.
http://sourceforge.net/projects/xming/
http://www.putty.org/

The Pi is fun.

Code: Select all
  421  wget http://sparemint.atariforge.net/sparemint/SRPMS/xswarm-2.3-1.src.rpm
  422  mkdir xswarm
  423  cd xswarm
  424  rpm2cpio ../xswarm-2.3-1.src.rpm > xswarm.cpio
  425  cpio -i --make-directories < xswarm.cpio
  428  tar -zxvf xswarm-2.3.tar.gz
  429  cd xswarm-2.3
  453  sudo apt-get install xorg-dev
  473  gcc -I /usr/include/X11 -L/usr/lib -lX11 -oxswarm xswarm.c
  475  ./xswarm -h
  499  ./xswarm -wyellow -cred -b500
  500  man -l xswarm.man
User avatar
Posts: 6
Joined: Wed May 30, 2012 8:45 pm
by AndrewS » Sun Jun 03, 2012 12:42 pm
usbspyder wrote:Amazed that an old program (1990) still compiles and works for X11 out of the box, and it is such a short program.

The "advantage" of programming directly against Xlib and not using some fancy higher-level GUI toolkit/framework/desktop-environment ;)
User avatar
Posts: 2789
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by Kev » Tue Jun 12, 2012 10:29 pm
For MongoDB on ARM this issue is relevant: https://jira.mongodb.org/browse/SERVER-1811

On Debian there seems to be a working package but ArchLinux hasn't and officially it isn't supported :(.
Posts: 2
Joined: Fri Jun 08, 2012 9:04 am