18.03.2010
Cross compiling Bluez for Buildroot
von mks.
Update: This post should be obsoleted by this one.
One optional target for our FALTER project (an autonomous UAV) is to have Bluetooth onboard to be able to get live telemetry data from it and possibly also for mission data up-/downloads.
For this we needed to cross compile Bluez for our Buildroot based Linux image. As it took me some time to figure out how to get it working, I think it might be helpful to others to post it here, because it’s not really hard to do, if you just know about the preconditions.
The problem is that Bluez uses pkg-config to find out where some libraries are. However the toolchain libraries are compiled with a prefix like /usr (the /usr on the target device) but you need Bluez to compile against something like /path/to/your/toolchain/usr. Pkg-config supports this through the PKG_CONFIG_SYSROOT_DIR environment variable, which was introduced in version 0.23.
So the most important thing to know is you need pkg-config 0.23. Version 0.22, that still comes with Ubuntu 10.04 (Alpha 3 as of now) is not enough! There’s a bug report for Debian to include the newer version since Apr 2008, but it seems nothing has happened yet. Fortunately someone already packaged it, get it here, or use my precompiled package (for Ubuntu 10.04 amd64).
Our target device is a x86-based embedded board, so we compile for i586. Of course you need to change this appropriately for your architecture.
You need to tell pkg-config, where your cross toolchain libs are with two environment variables:
$ export PKG_CONFIG_SYSROOT_DIR=<path_to_buildroot>/build_i586/staging_dir $ export PKG_CONFIG_LIBDIR=$PKG_CONFIG_SYSROOT_DIR/usr/lib/pkgconfig
Then configure for cross compiling (note the –host option):
$ ./configure --prefix=/usr --sysconfdir=/etc --host=i586-linux
You are then ready to build with make and can install it with make install DESTDIR=<your_target_fs>.
I will probably try to write a patch to get this into the Buildroot buid system in the next days.
29.02.2012
06:35
sudesh ¶
Hello .. I am facing same problem ..i.e i dono how to cross compile and put it on to mini2440 board(friendly arm)… would you plz help
29.02.2012
09:28
mks ¶
Hello sudesh, I doubt I am the right one for this, but I can *try*.
Bluez should be included since November last year: https://bugs.busybox.net/show_bug.cgi?id=1357
Actually, you should not need the way described here. If compiling it right out of Buildroot fails, did you consider reporting a bug on their bugtracker?