Changes between Version 9 and Version 10 of CompilationGuide/RaspberryPi


Ignore:
Timestamp:
May 3, 2014, 5:48:06 AM (4 years ago)
Author:
Timothy_Gu
Comment:

Decrease header level

Legend:

Unmodified
Added
Removed
Modified
  • CompilationGuide/RaspberryPi

    v9 v10  
    11[[PageOutline(1-100,Contents)]] 
    22 
    3 = Introduction = 
     3== Introduction == 
    44[[Image(Raspberry_Pi_600x400.jpg)]] 
    55 
     
    1212(TODO: The comparison table of different ways to compile FFmpeg for Raspbian) 
    1313 
    14 = Cross-compiling FFmpeg for Raspbian = 
     14== Cross-compiling FFmpeg for Raspbian == 
    1515We will describe here the method to cross-compile FFmpeg for Raspbian. First, we will prepare our build environment. Then we will show how to compile common additional libraries that FFmpeg might use (for example libx264). And finally we'll show how to compile the latest (and greatest) version of FFmpeg that will run on Raspbian. 
    1616 
    17 == Preparing the environment == 
     17=== Preparing the environment === 
    1818To successfully cross-compile things, we need something called a [http://en.wikipedia.org/wiki/Toolchain Toolchain] (a set of programming tools that are used to create another computer program). We need a toolchain that will be able to produce binaries, specific to the ARM architecture and the Raspbian itself. Now, there are a lot of already created toolchains for Raspbian and if you like to speed up things, you could just go find one of them and install it, but be aware that whatever toolchain you download, it might not be optimized for both your own operating system and Raspbian. If you compile your own toolchain, you can be sure that you'll be able to use all the available optimizations that your operating system and your Raspbian support. 
    1919 
    2020The [http://crosstool-ng.org/ crosstool-ng] is a tool used to create a custom toolchain. We'll use it to create our own toolchain which we can then use to compile anything we want for the Raspbian. So, let's prepare everything to first build our toolchain. 
    2121 
    22 === Building the crosstool-ng === 
     22==== Building the crosstool-ng ==== 
    2323The following section is mostly inspired by [http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/ How to build a cross compiler for your Raspberry Pi]. 
    2424 
     
    3838Although, the error complained about "makeinfo", it appears that, in Debian, this package is named "texinfo". Also consider installing texi2html package. 
    3939 
    40 === Building the toolchain === 
     40==== Building the toolchain ==== 
    4141Now that we built crosstool-ng, we can build our RPi toolchain.  
    4242 
     
    7979}}} 
    8080 
    81 === Quick test of the toolchain === 
     81==== Quick test of the toolchain ==== 
    8282Let's make a quick sanity check of our ARM compiler: 
    8383 
     
    9999Copy the "test" binary to your RPi and run it. It should display a familiar "Hello, world!" text. 
    100100 
    101 == Compiling additional libraries needed for FFmpeg == 
     101=== Compiling additional libraries needed for FFmpeg === 
    102102This section will describe how to compile some common libraries that are usually used by FFmpeg, like libx264 or libaacplus, etc. 
    103103 
    104 === Compiling libaacplus === 
     104==== Compiling libaacplus ==== 
    105105{{{ 
    106106cd /my/path/where/i/keep/my/source/code 
     
    124124That way you are telling the compiler where are the dependencies, that you also compiled for RPi, located, in order to successfully  compile that "other library" too. 
    125125 
    126 === Compiling libx264 === 
     126==== Compiling libx264 ==== 
    127127{{{ 
    128128cd /my/path/where/i/keep/my/source/code 
     
    136136Note that we use CCPREFIX environment variable here, to specify the prefix of all the tools in a toolchain, to be used for this build (it instructs the shell not to call cc, gcc, g++ and other standard tools, but rather to call /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-cc, /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc, /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++, etc that will build ARM binaries and libraries). 
    137137 
    138 === Compiling ALSA library === 
     138==== Compiling ALSA library ==== 
    139139{{{ 
    140140cd /my/path/where/i/keep/my/source/code 
     
    147147}}} 
    148148 
    149 == Compiling FFmpeg == 
     149=== Compiling FFmpeg === 
    150150This part is the same for all the subsequent examples: 
    151151{{{ 
     
    155155}}} 
    156156 
    157 === Basic FFmpeg, without additional libraries === 
     157==== Basic FFmpeg, without additional libraries ==== 
    158158{{{ 
    159159./configure --enable-cross-compile --cross-prefix=${CCPREFIX} --arch=armel --target-os=linux --prefix=/my/path/were/i/keep/built/arm/stuff 
     
    162162}}} 
    163163 
    164 === FFmpeg with libaacplus, libx264 and alsa-lib === 
     164==== FFmpeg with libaacplus, libx264 and alsa-lib ==== 
    165165{{{ 
    166166./configure --enable-cross-compile --cross-prefix=${CCPREFIX} --arch=armel --target-os=linux --prefix=/my/path/were/i/keep/built/arm/stuff --enable-gpl --enable-libx264 --enable-nonfree --enable-libaacplus --extra-cflags="-I/my/path/were/i/keep/built/arm/stuff/include" --extra-ldflags="-L/my/path/were/i/keep/built/arm/stuff/lib" --extra-libs=-ldl 
     
    174174}}} 
    175175 
    176 = Conclusion = 
     176== Conclusion == 
    177177After you've built your FFmpeg for RPi, copy `ffmpeg`, `ffplay` and `ffserver` binaries from "/my/path/were/i/keep/built/arm/stuff/bin/" to your Raspberry Pi and try it to see how it works :) 
    178178