Hi Wookey,

I confirm that I just got it to work with natty :D

I have put my notes on the FreeRDP wiki, I'll expand the article later:
http://www.freerdp.com/wiki/doku.php?id=arm_cross_compiling

Since we're using libtool, the executables are wrapped behind scripts that set up proper environment variables for non-installed libraries. I managed to get around the broken path problem between the current system and the target system by creating the same user in both the chroot environment and the target environment, and mount the FreeRDP source directory at the exact same absolute path on the pandaboard using sshfs. I can now compile on my powerful computer, and use the results instantly on the pandaboard :)

I finally have a decent cross-compiling setup :) This is going to save me a lot of time!

Thank you,
- Marc-Andre

On Sun, Jun 26, 2011 at 11:20 AM, Marc-André Moreau <marcandre.moreau@gmail.com> wrote:
Hi Wookey,

I just managed to get it to compile on oneiric. I think I figured out the problem related to pthreads: I had to install libpthread-stubs0 libpthread-stubs0-dev for the current architecture, not the target architecture, which is a bit weird, but it works. The configure script would complain about missing pthreads stubs, which is why I installed it first with xapt, without success, but when I installed it for the current architecture, the configure script worked and FreeRDP built without linker errors.

I used your updated xapt package in oneiric to correctly fetch the stuff. Here are my updated notes:

# bootstrap ubuntu oneiric
sudo debootstrap oneiric oneiric-armel

# chroot to new environment
sudo chroot oneiric-armel

# mount partitions
mount -t proc proc /proc
mount -t devpts none /dev/pts

# export environment variables
export LC_ALL=C

# append "universe" after "main" in sources.list
sed -i 's/main/main universe/' /etc/apt/sources.list

# add source repository
sudo echo "deb [arch=armel] http://ports.ubuntu.com/ oneiric main universe" >> /etc/apt/sources.list

# update and install packages
apt-get update
apt-get install gcc-arm-linux-gnueabi libgcc1-armel-cross xapt wget

wget http://wookware.org/software/repo/pool/main/e/emdebian-crush/xapt_2.2.16ubuntu1_all.deb
dpkg -i xapt_2.2.16ubuntu1_all.deb

sudo apt-get install libpthread-stubs0 libpthread-stubs0-dev
sudo apt-get install libtool automake autoconf git pkg-config

xapt -a armel -m libssl-dev libx11-dev libxv-dev libxkbfile-dev libxcursor-dev libasound2-dev libxcb1 libxcb1-dev libdirectfb-dev libc6 libc6-dev zlib1g zlib1g-dev libcups2-dev libpthread-stubs0 libpthread-stubs0-dev

PKG_CONFIG_PATH=/usr/arm-linux-gnueabi/lib/pkgconfig ./configure --host=arm-linux-gnueabi


I am now wondering if the same would work in natty. I'll have to give it a try, if it works, I won't have to update my pandaboard to oneiric.


On Fri, Jun 24, 2011 at 5:49 AM, Wookey <wookey@wookware.org> wrote:
+++ Marc-André Moreau [2011-06-23 17:40 -0400]:

[I wrote a response to this for 4hrs last night then my mail server
crashed and lost it all - <mutter>. trying agin...]

> Hi,
>
> I am Marc-Andre from the FreeRDP project, an open source RDP client. I want to
> work on optimizing FreeRDP for ARM using the NEON processor extensions.

Welome

> It is my first time cross-compiling, so thank you for your understanding.

Welcome to the joyful world of cross-building :-)

> I have asked some questions on IRC, and read various pages from the wiki, but I
> haven't managed to successfully cross-compile FreeRDP yet. Compiling directly
> on the pandaboard works, but it is atrociously slow. I have made a chroot
> environment following and adapting the instructions from the following wiki
> page: https://wiki.linaro.org/Platform/DevPlatform/CrossCompile/UsingXdeb

Nothing wrong with this method, and it is reliable, but I find it
quicker and easier to use multistrap and do:
multistrap -f

> I have tried both xdeb and xapt, both causing problems.

> xapt:
>
> I managed to fetch and convert packages with xapt, using the following command:
> sudo xapt -a armel -k -b --suite natty --mirror http://ports.ubuntu.com/
> libssl-dev libx11-dev libxv-dev libxkbfile-dev libxcursor-dev libasound2-dev
> libxcb1 libxcb1-dev libdirectfb-dev libc6 libc6-dev zlib1g zlib1g-dev
>
> The problem is then that xapt will fail to install the converted packages,
> saying the package architecture is different from the current architecture, as
> well as missing dependencies. I worked around the problem with this ugly hack:
>
> cd /var/lib/xapt/output/
> sudo dpkg -i --force-all *.deb

You are suffering from this problem:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=629595 which is
because we are in the middle of a transition to multiarch packages.
When xapt/dpkg-cross were written it was assumed that thay would
simply ignore multiarched packages. However in practice it turns out
that that's not the case and currently they need to be converted back
to old-style locations. that needs the -m option supplying to xapt.
The version in natty is too old to have option.

So if you do sudo xapt -a armel -b libssl-dev libx11-dev libxv-dev \
libxkbfile-dev libxcursor-dev libasound2-dev libxcb1 libxcb1-dev \
libdirectfb-dev libc6 libc6-dev zlib1g zlib1g-dev libcups2-dev

on a wheezy box/chroot then all that stuff get downloaded, converted
and installed correctly.

> Following this, I could get the FreeRDP configure script to work, even though
> it would fail to detect X11 properly:
>
> PKG_CONFIG_PATH=/usr/arm-linux-gnueabi/lib/pkgconfig ./configure --host=
> arm-linux-gnueabi --with-neon

X11 is detected OK for me:
FreeRDP configure result:

Cryptography : openssl
TLS          : enabled
Sound        : yes
Printer      : no
CUnit        : no
X11          : yes
DirectFB     : no


> When trying to build after that, it will still fail to link in the end,
> complaining about missing libraries such as zlib, X11, crypto, etc. I tried
> installing various packages more with xapt, but I couldn't get it to work.

If I do PKG_CONFIG_LIBDIR=/usr/arm-linux-gnueabi/lib/pkgconfig dpkg-buildpackage -aarmel

then it all builds OK (on wheezy), except that the printer support is
not found. The confiure script needs checking to find out why that's
failing. That path-setting shouldn't be neeed either but it's not
working without it, even with the cross-version of pkg-config
installed. Again, needs further investigation.

You can work round the cups non-identificatin with
HAVE_CUPS=1 PKG_CONFIG_LIBDIR=/usr/arm-linux-gnueabi/lib/pkgconfig dpkg-buildpackage -aarmel

To get this working on natty you would need to get the current xapt, an
ubuntu port of which is available here:

http://wookware.org/software/repo/ natty main
or just here:
http://wookware.org/software/repo/pool/main/e/emdebian-crush/xapt_2.2.16ubuntu1_all.deb

however there is then a link failure, when it tries to link the wrong
arch of libpthread.so:
/usr/lib/gcc/arm-linux-gnueabi/4.5.2/../../../../arm-linux-gnueabi/bin/ld:
skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.so when searching for -lpthread
/usr/lib/x86_64-linux-gnu/libpthread.a: could not read symbols: File format not recognized
collect2: ld returned 1 exit status

Again - needs looking into.

> xdeb:
>
> I tried the following:
> root@workstation:/# xdeb -a armel --prefer-apt libssl-dev libx11-dev libxv-dev
> libxkbfile-dev libxcursor-dev libasound2-dev
>...
> No source package found: libssl-dev
>
> Or, alternatively, the following:
> root@workstation:/# xdeb -a armel --convert libssl-dev libx11-dev libxv-dev
> libxkbfile-dev libxcursor-dev libasound2-dev
>..
> IOError: [Errno 2] No such file or directory: './libssl-dev'
>
> Here is my sources.list file:
> root@workstation:/# cat /etc/apt/sources.list
> deb http://archive.ubuntu.com/ubuntu natty main universe
> deb-src http://archive.ubuntu.com/ubuntu natty main universe
> deb [arch=armel] http://ports.ubuntu.com/ natty main universe
> deb-src [arch=armel] http://ports.ubuntu.com/ natty main universe

That looks OK (except the last line should be:
deb-src http://ports.ubuntu.com/ natty main universe
(It doesn't actually break anything - just makes no sense - Have I
left that in a doc somewhere?)

So for xdeb you want this command:

xdeb -a armel --prefer-apt --only-explicit freerdp

On wheezy that dies quickly with a package conflict:
he following packages have unmet dependencies:
 heimdal-dev : Conflicts: libkrb5-dev but 1.9.1+dfsg-1+b1 is to be
installed
 libdb-dev : Depends: libdb5.1-dev but it is not going to be installed
            Conflicts: libdb4.8-dev but 4.8.30-8 is to be installed
 libdb4.8-dev : Conflicts: libdb-dev but 5.1.4 is to be installed
 libkrb5-dev : Conflicts: heimdal-dev but 1.4.0-6 is to be installed
 unixodbc-dev : Conflicts: libiodbc2-dev but 3.52.7-2 is to be installed
 E: Broken packages

Not sure what's going on there, but it's not much use.

On natty things go much better and it downloads, crosses and builds a
load of stuff until falling over with :

pkg-deb: building package libosmesa6-armel-cross' in ./libosmesa6-armel-cross_7.10.2-0ubuntu2_all.deb'.
dpkg-cross: package libegl1-mesa-drivers doesn't provide any useful files. Skipping.

Which is due to this bug:
https://bugs.launchpad.net/ubuntu/+source/xdeb/+bug/731079
(xdeb stops if it comes across a package it thought it should cross
which is in fact dpkg-cross 'NULL'). This is rather annoying and I
think I have a fix mostly-done but it's not merged yet - need to check
where that got to. You can fix it by adding the offending package to
the xdeb blacklist )that's how it currently expects to work):
so add libosmesa6 to /etc/xdeb/xdeb.conf in the 'blacklist' section.

However after doing that it doesn't get much further before:
.:terminate called after throwing an instance of 'std::out_of_range'

> I'm stuck at this point. Can anybody point me towards possible solution paths
> on how to cross-compile FreeRDP for ARM, given the above information?

So, the easiest way to get cross-building is to do it on a debian
wheezy machine/chroot where the tools and build work OK. As you want
to do neon dev then you may need to install a new-enough
cross-toolchain, which probably means a linaro one.

I'll look into the natty build failures and see if we can get that
going for you. This is clearly a package that ought to cross OK.

So, now you know why people native-build :-) there are an awful lot
fewer things to go wrong and the tools are much more mature. There is
plenty of work going on at the moment to improve the situation, and at
least your source package is farily well-behaved (many aren't). It
does look like it needs a couple of fixes though so a plain
dpkg-buildpackage -aarmel would work as expected.

So, is a wheezy-based build sufficient for you for the time being? Or
do you have to have it building on natty to do useful dev?

Wookey
--
Principal hats:  Linaro, Emdebian, Wookware, Balloonboard, ARM
http://wookware.org/