Cross-Compiling for Ubuntu ARM by ffmpeg Example
This has been a delayed post since I only figure out how to solve configure
error just now. It wasn’t really necessary to cross-compile last year because compiling ffmpeg
directly on the ARM-board finished overnight (despite the low CPU). Anyway, in this post I’m still using the board to easily retrieve package dependencies from Ubuntu ARM repository. Toolchain used is arm-linux-gnueabi-gcc-
. The following steps will apply in general:
- download source file (that is
ffmpeg
in this example) - retrieve development library/build dependecies
- place header files and dependency libraries into toolchain path
configure
with toolchainmake
and create.deb
installer package withcheckinstall
Prior to anything, install Linaro toolchain by adding their repo first:
$ sudo add-apt-repository ppa:linaro-maintainers/toolchain $ sudo apt-get install gcc-arm-linux-gnueabi
A complete guide on how to compile ffmpeg can be found in their wiki. It applies generally. So, I’ll just skip to following configure
:
[ubuntu-desktop]$ ./configure --cross-prefix=arm-linux-gnueabi- --enable-cross-compile --target-os=linux --arch=arm --cpu=cortex-a8 --extra-cflags='-march=armv7-a -mfpu=neon -mfloat-abi=softfp' --enable-libtheora
As an example, the above configure requires Theora libraries. libtheora-dev
itself requires libogg-dev
. Use apt-get
on the board to get them from Ubuntu ARM repository. Get the .deb
files from /var/cache/apt/archives/
of the ARM-board to your desktop and extract them as root
:
[root@ubuntu-desktop]$ dpkg -x libogg-dev_1.2.2~dfsg-1ubuntu1_armel.deb /usr/local/cross-compile [root@ubuntu-desktop]$ dpkg -x libtheora-dev_1.1.1+dfsg.1-3_armel.deb /usr/local/cross-compile
The above /usr/local/cross-compile
is just a temporary directory. The toolchain needs header files and dependency libraries to be placed inside /usr/arm-linux-gnueabi/include/
and /usr/arm-linux-gnueabi/lib/
consecutively. In my case I created the following link for header’s include
:
[root@ubuntu-desktop]$ cd /usr/arm-linux-gnueabi/include [root@ubuntu-desktop]$ ln -s /usr/local/cross-compile/usr/include/theora [root@ubuntu-desktop]$ ln -s /usr/local/cross-compile/usr/include/ogg
and copied these from /usr/local/cross-compile/usr/lib
:
libogg.a libogg.so libtheora.a libtheoradec.a libtheoradec.la libtheoradec.so libtheoraenc.a libtheoraenc.la libtheoraenc.so libtheora.la libtheora.so
After successful configure
, run make
(this will take some time), and then pack the whole working directory to the ARM-board. Instead of doing make install
in the ARM-board, use checkinstall
to install and create the .deb
package. This way we can make use of dpkg
to uninstall or re-install in the manner of package manager.
[root@beagleboard]$ sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(./version.sh)" \ --backup=no --deldoc=yes --default
Please mind that even if we put “--install=no
“, the above checkinstall
will overwrite all ffmpeg
binaries in /usr/local/bin/
. This is the reason why I move the process to the ARM-board: to keep other running version on my desktop stays as it is.
Check the test of streaming from our cross-compiled ffmpeg
in previous post.
A Little History
When first attempt to configure
exited with ERROR: libtheora not found
, I found the following test failed in the output log:
$ arm-linux-gnueabi-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mcpu=cortex-a8 -std=c99 -fomit-frame-pointer -marm -pthread -E -o /tmp/ffconf.UdYctJgq.o /tmp/ffconf.mwXpf9Tl.c ... /usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../../arm-linux-gnueabi/bin/ld: cannot find -ltheoraenc /usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../../arm-linux-gnueabi/bin/ld: cannot find -ltheoradec /usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../../arm-linux-gnueabi/bin/ld: cannot find -logg
What was inside the above temporary file (/tmp/ffconf.mwXpf9Tl.c
):
1 2 | #include <theora/theoraenc.h> int x; |
You can run that test to check whether all dependencies are met.
8 thoughts on “Cross-Compiling for Ubuntu ARM by ffmpeg Example”