Hello all,
I am currently running the official Debian squeeze image on my RasPi. I am currently able to compile programs for it on a server setup to use Scratchbox (a cross-compiliation toolkit). I was wondering if there is a way i can compile programs using scratchbox that will work with Raspbian's armhf.
Thanks,
Shawn
Cross Compiling for Raspbian?
12 posts
- Posts: 19
- Joined: Mon May 28, 2012 7:44 pm
I haven't worked with scratchbox myself but AIUI you would have to build a cross toolchain for scratchbox with appropriate compiler options for raspbian. However I have no idea how to do this within the framework provided by scratchbox.
The key compiler options for raspbian are "-march=armv6 -mfpu=vfp -mfloat-abi=hard"
The key compiler options for raspbian are "-march=armv6 -mfpu=vfp -mfloat-abi=hard"
- Moderator
- Posts: 1433
- Joined: Wed Dec 28, 2011 11:45 pm
Thanks for the quick response,
I was afraid I would have to make a toolchain by hand. Thank you for telling me the compiler options, I will be sure to upload the toolchain when I am done with it.
--Shawn
I was afraid I would have to make a toolchain by hand. Thank you for telling me the compiler options, I will be sure to upload the toolchain when I am done with it.
--Shawn
- Posts: 19
- Joined: Mon May 28, 2012 7:44 pm
Update: Using the default ARMv6 Toolkit, I tried compiling a simple hello world with gcc. When I executed "gcc -o armhfhellotest hello.c -march=armv6 -mfpu=vfp -mfloat-abi=hard" I got the following error message: "hello.c:1: sorry, unimplemented: -mfloat-abi=hard and VFP" Am I doing something wrong? I am fairly new to cross-compiling and not sure what to make of this error.
Thanks,
Shawn
Thanks,
Shawn
- Posts: 19
- Joined: Mon May 28, 2012 7:44 pm
I built a cross-compiler toolchain for raspbian using crosstool-NG (http://crosstool-ng.org/)
Here's the set of configuration options I used (taken from build.log): http://pastebin.com/w8gBXmPY
I'm not sure how this can be integrated into scratchbox though.
Here's the set of configuration options I used (taken from build.log): http://pastebin.com/w8gBXmPY
I'm not sure how this can be integrated into scratchbox though.
- Posts: 8
- Joined: Sat May 12, 2012 10:56 pm
- Location: New York
I succeeded sticking to this tutorial http://biffengineering.com/wiki/index.p ... nvironment
I am using Linux Mint Debian.
What needs to be done differently is:
Add all the arch options before building CT-NG
Change armel to armhf in the foldernames (not strictly necessary)
Use Raspbian as source for debootstrap! The command is:
maybe you first have to add the key using
I am using Linux Mint Debian.
What needs to be done differently is:
Add all the arch options before building CT-NG
Change armel to armhf in the foldernames (not strictly necessary)
Use Raspbian as source for debootstrap! The command is:
- Code: Select all
sudo debootstrap --verbose --keyring /etc/apt/trusted.gpg --arch armhf --foreign wheezy \
$HOME/sbox2/rootfs/armhf http://archive.raspbian.org/raspbian/
maybe you first have to add the key using
wget http://archive.raspbian.org/raspbian.public.key;apt-key add raspbian.public.key
- Posts: 2
- Joined: Wed Jun 20, 2012 11:29 pm
J0s3f wrote:I succeeded sticking to this tutorial http://biffengineering.com/wiki/index.p ... nvironment
I am using Linux Mint Debian.
What needs to be done differently is:
Add all the arch options before building CT-NG
Change armel to armhf in the foldernames (not strictly necessary)
Use Raspbian as source for debootstrap! The command is:
- Code: Select all
sudo debootstrap --verbose --keyring /etc/apt/trusted.gpg --arch armhf --foreign wheezy \
$HOME/sbox2/rootfs/armhf http://archive.raspbian.org/raspbian/
maybe you first have to add the key usingwget http://archive.raspbian.org/raspbian.public.key;apt-key add raspbian.public.key
Hmmm I'm also sticking to the tutorial but I get stuck building scratchbox. Whiles compiling I get the error:
- Code: Select all
mard0@mard0-Inspiron-1546:~/sbox2/src/scratchbox2$ make
make[1]: Entering directory `/home/mard0/sbox2/src/scratchbox2/obj-32'
make[2]: Entering directory `/home/mard0/sbox2/src/scratchbox2/obj-32'
echo "/* Automatically generated file. Do not edit. */" >include/scratchbox2_version.h
echo '#define SCRATCHBOX2_VERSION "'`cat .version`'"' >>include/scratchbox2_version.h
echo '#define LIBSB2_SONAME "'"libsb2.so.1"'"' >>include/scratchbox2_version.h
[CC] luaif/sb_log.o
../luaif/sb_log.c: In function ‘write_to_logfile’:
../luaif/sb_log.c:117:4: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
../luaif/sb_log.c:122:4: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
[ARCHIVE] luaif/libluaif.a
[SHLIB] preload/libsb2.so
[LD] utils/sb2-show
utils/sb2-show.o: In function `call_sb2__load_and_execute_lua_file__':
/home/mard0/sbox2/src/scratchbox2/obj-32/../utils/sb2-show.c:93: undefined reference to `dlsym'
utils/sb2-show.o: In function `call_sb2show__map_path2__':
/home/mard0/sbox2/src/scratchbox2/obj-32/../utils/sb2-show.c:75: undefined reference to `dlsym'
utils/sb2-show.o: In function `call_sb2show__execve_mods__':
/home/mard0/sbox2/src/scratchbox2/obj-32/../utils/sb2-show.c:82: undefined reference to `dlsym'
utils/sb2-show.o: In function `call_sblog_vprintf_line_to_logfile':
/home/mard0/sbox2/src/scratchbox2/obj-32/../utils/sb2-show.c:107: undefined reference to `dlsym'
utils/sb2-show.o: In function `main':
/home/mard0/sbox2/src/scratchbox2/obj-32/../utils/sb2-show.c:774: undefined reference to `dlopen'
/home/mard0/sbox2/src/scratchbox2/obj-32/../utils/sb2-show.c:781: undefined reference to `dlsym'
utils/sb2-show.o: In function `call_sb2__lua_c_interface_version__':
/home/mard0/sbox2/src/scratchbox2/obj-32/../utils/sb2-show.c:97: undefined reference to `dlsym'
utils/sb2-show.o: In function `call_sb2__set_active_exec_policy_name__':
/home/mard0/sbox2/src/scratchbox2/obj-32/../utils/sb2-show.c:89: undefined reference to `dlsym'
utils/sb2-show.o: In function `call_sb2show__get_real_cwd__':
/home/mard0/sbox2/src/scratchbox2/obj-32/../utils/sb2-show.c:101: undefined reference to `dlsym'
utils/sb2-show.o: In function `call_sb2show__binary_type__':
/home/mard0/sbox2/src/scratchbox2/obj-32/../utils/sb2-show.c:70: undefined reference to `dlsym'
utils/sb2-show.o:/home/mard0/sbox2/src/scratchbox2/obj-32/../utils/sb2-show.c:113: more undefined references to `dlsym' follow
collect2: ld returned 1 exit status
make[2]: *** [utils/sb2-show] Error 1
make[2]: Leaving directory `/home/mard0/sbox2/src/scratchbox2/obj-32'
make[1]: *** [regular] Error 2
make[1]: Leaving directory `/home/mard0/sbox2/src/scratchbox2/obj-32'
make: *** [multilib] Error 2
I noticed that the scratchbox git hasn't been updated for 15days, so I'm guessing that I'm missing something. I'm trying to build it on ubuntu 12.04. Where did you veer off from the tutorial and what did you change except using the raspbian repro?
Grtz
- Posts: 52
- Joined: Wed Oct 26, 2011 4:23 pm
I changed --host=i386 to --host=AMD64, because I am using Linux Mint Debian 64bit.
Apart from that, I changed nothing!
It looks like it cannot find some lib it wants to link to. Maybe you are missing some package on Ubuntu?
Apart from that, I changed nothing!
It looks like it cannot find some lib it wants to link to. Maybe you are missing some package on Ubuntu?
- Posts: 2
- Joined: Wed Jun 20, 2012 11:29 pm
when I compile a cross compiler (I do it from scratch, so using gcc, binutils, uClibc), I normally do:
so give the full name, and for me specify host and build (as well as target) as I compile and run the compile on an x86_64, but producing code for an arm.
Stuff to make sure it goes in the right place, and independnet of whats already on the computer
And that its aimed at the right CPU:
Which you'll need to change for the Pi to v6, the right cpu, and probably the fpu.
Then whatever lanugages and other bits you want:
Many of those will only compile when you've got the c library in place, so for example diable threads, shared, tls etc first time round ...
- Code: Select all
--target=armv7-hardfloat-linux-gnueabi --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu
so give the full name, and for me specify host and build (as well as target) as I compile and run the compile on an x86_64, but producing code for an arm.
Stuff to make sure it goes in the right place, and independnet of whats already on the computer
- Code: Select all
--prefix=/home/arm --with-sysroot=/home/arm --with-lib-path=/usr/lib:/lib --with-native-system-header-dir=/usr/include
And that its aimed at the right CPU:
- Code: Select all
--enable-neon --with-arch=armv7-a --with-cpu=cortex-a9 --with-fpu=vfpv3 --with-float=hard --with-abi=aapcs-linux
Which you'll need to change for the Pi to v6, the right cpu, and probably the fpu.
Then whatever lanugages and other bits you want:
- Code: Select all
--enable-languages=c --enable-threads --enable-tls --enable-shared --disable-libgomp --disable-nls --disable-multilib --disable-libmudflap --disable-libssp --disable-libgomp --disable-libquadmath --with-libliberty
Many of those will only compile when you've got the c library in place, so for example diable threads, shared, tls etc first time round ...
- Posts: 57
- Joined: Mon Jan 30, 2012 4:27 pm
I found this tutorial to be particularly helpful:
http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/
http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/
- Posts: 1
- Joined: Fri Sep 28, 2012 10:03 pm
J0s3f wrote:I succeeded sticking to this tutorial http://biffengineering.com/wiki/index.p ... nvironment
I am using Linux Mint Debian.
What needs to be done differently is:
Add all the arch options before building CT-NG
Change armel to armhf in the foldernames (not strictly necessary)
Use Raspbian as source for debootstrap! The command is:
- Code: Select all
sudo debootstrap --verbose --keyring /etc/apt/trusted.gpg --arch armhf --foreign wheezy \
$HOME/sbox2/rootfs/armhf http://archive.raspbian.org/raspbian/
maybe you first have to add the key usingwget http://archive.raspbian.org/raspbian.public.key;apt-key add raspbian.public.key
Just as an FYI, I've moved from my biffengineering site to a new domain. All the info was transfered but got rid of the wiki so once the redirect stops working go here http://jecxjo.motd.org/code/blosxom.cgi/devel/cross_compiler_environment
IRC (w/ SSL Support): jecxjo.mdns.org
Blog: http://jecxjo.motd.org/code
ProjectEuler Friend: 79556084281370_44d12dd95e92b1d9453aba2bdc94101b
Blog: http://jecxjo.motd.org/code
ProjectEuler Friend: 79556084281370_44d12dd95e92b1d9453aba2bdc94101b
jecxjo wrote:J0s3f wrote:I succeeded sticking to this tutorial http://biffengineering.com/wiki/index.p ... nvironment
I am using Linux Mint Debian.
What needs to be done differently is:
Add all the arch options before building CT-NG
Change armel to armhf in the foldernames (not strictly necessary)
Use Raspbian as source for debootstrap! The command is:
- Code: Select all
sudo debootstrap --verbose --keyring /etc/apt/trusted.gpg --arch armhf --foreign wheezy \
$HOME/sbox2/rootfs/armhf http://archive.raspbian.org/raspbian/
maybe you first have to add the key usingwget http://archive.raspbian.org/raspbian.public.key;apt-key add raspbian.public.key
Just as an FYI, I've moved from my biffengineering site to a new domain. All the info was transfered but got rid of the wiki so once the redirect stops working go here http://jecxjo.motd.org/code/blosxom.cgi/devel/cross_compiler_environment
Thanks for the tutorial. I got stuck at the "Cross Compiled Libraries" section though, as the 'apt-cross' tool seems to have been deprecated, and is not available for Ubuntu 12.10. Do you know of a replacement?
- Posts: 3
- Joined: Sat Dec 01, 2012 7:35 pm