1 <!doctype linuxdoc system>
4 <title>Cross compiling VLC for ARM-Linux based platforms</title>
5 <author>Marc Ariberti <tt><htmlurl url="mailto:marcari@videolan.org" name="<marcari@videolan.org>"></tt></author>
6 <date>v0.0.1, 13 march 2003</date>
8 This document describes all the steps to cross compile vlc for ARM based
9 platforms. It describes how to build a cross compilation toolchain, how to
10 build the libraries needed by vlc and the compilation of the vlc itself.
17 <heading>Introduction</heading>
19 This document is only a first draft. It does not intend to cover all the
20 subject. You may still have some problems at some steps or find better
21 way to do them. If you have any comment do not hesitate to contact us.
24 <heading>Which platforms are targeted ?</heading>
26 I will describe here how to compile vlc for an ARM based
27 PDA running linux. It includes for example :
29 <item>Compaq - iPaq (H36xx, H38xx,...), using Familiar Linux
31 <item>GNU Portable Environment (GPE)
35 <item>YOPY/Linupy</item>
41 <heading>Requirements for cross-compilation</heading>
44 <heading>Why cross-compiling ?</heading>
46 It is of course possible to compile directly on the targeted platform.
47 But there are a lot of great advantages to cross-compile :
49 <item>The most important one is probably the speed, because a
50 desktop computer is most of the time faster than a PDA for
52 <item>Another big problem is that a complete compilation toolchain
53 does take a great amount of disk space. And this space is usually
54 very limited on embedded systems.</item>
55 <item>And there also may not be enough memory to compile big files.</item>
62 <heading>Building the toolchain</heading>
64 <heading>Prerequisite</heading>
66 <heading>Importants paths</heading>
68 During this section, we will use the following paths :
70 <p>I would personally advise to compile everything as a normal user and
71 then install everything as root.</p>
73 <heading>${SRCDIR}</heading>
75 This is where the sources will be located and where the compilation
77 (eg: <tt>/usr/src</tt> or <tt>/home/foobar/arm-src</tt>).
81 <heading>${PREFIX}</heading>
82 <p>This is where you want to install your cross compilation toolchain.
83 It can be either installed system-wide (in <tt>/usr/local/arm/2.95.3</tt> for example). Installation steps (i.e. <tt>make install</tt>) will have
84 to be done as <tt>root</tt>.
85 Or it can be installed in user-land, for the user's own use (<tt>/home/foobar/arm/2.95.3</tt> for example).
86 In this paper, the chosen prefix is <tt>/usr/local/arm/2.95.3</tt>,
87 you will have to adapt the commands to what you choose..
92 <heading>Files needed</heading>
93 <p>Download the following files and put them in the <bf>${SRCDIR}</bf>.
94 Most of them are available on the <htmlurl url="http://www.videolan.org/vlc/download-sources.html" name="VideoLAN website">.
96 <item><tt>binutils-2.11.2.tar.gz</tt></item>
97 <item><tt>linux-2.4.19.tar.bz2</tt></item>
98 <item><tt>patch-2.4.19-rmk4.bz2</tt></item>
99 <item><tt>gcc-2.95.3.tar.gz</tt></item>
100 <item><tt>gcc-2.95.3.diff.bz2</tt></item>
101 <item><tt>gcc-2.95.3.diffbis.bz2</tt></item>
102 <item><tt>gcc-2.95.3.diff2</tt></item>
103 <item><tt>glibc-2.2.5.tar.gz</tt></item>
104 <item><tt>glibc-linuxthreads-2.2.5.tar.gz</tt></item>
105 <item><tt>SDL-1.2.5.tar.gz</tt></item>
106 <item><tt>glib-1.2.10.tar.gz</tt></item>
107 <item><tt>ffmpeg.tar.gz</tt></item>
108 <item><tt>mad-0.14.2b.tar.gz</tt></item>
109 <item><tt>flac-1.1.0.tar.gz</tt></item>
110 <item><tt>libdvbpsi-0.1.2.tar.gz</tt></item>
111 <item><tt>a52dec-0.7.4.tar.gz</tt></item>
117 <heading>Binutils</heading>
118 <p>Compiling binutils is pretty simple :
120 tar -xzf binutils-2.11.2.tar.gz
122 ./configure --target=arm-linux --prefix=/usr/local/arm/2.95.3
129 <heading>Preparing linux kernel</heading>
132 tar -xzf linux-2.4.19.tar.bz2
133 bunzip2 patch-2.4.19-rmk4.bz2
135 patch -p1 < ../patch-2.4.19-rmk4.bz2
136 make clean ARCH=arm CROSS_COMPILE=arm-linux-
137 make ARCH=arm h3600_config
139 <bf>Do not forget</bf> to save the configuration even if no changes
142 make ARCH=arm menuconfig
143 make symlinks ARCH=arm CROSS_COMPILE=arm-linux-
144 mkdir -p /usr/local/arm/2.95.3/arm-linux/include
145 cp -Rf include/asm include/asm-arm include/linux \
146 /usr/local/arm/2.95.3/arm-linux/include
147 cd /usr/local/arm/2.95.3/arm-linux
148 ln -s include sys-linux
153 <heading>Basic cross compiler (gcc)</heading>
156 tar -xvzf gcc-2.95.3.tar.gz
157 bunzip2 gcc-2.95.3.diff.bz2
158 bunzip2 gcc-2.95.3.diffbis.bz2
159 patch -p1 -d gcc-2.95.3 < gcc-2.95.3.diff
160 patch -p1 -d gcc-2.95.3 < gcc-2.95.3.diffbis
162 ./configure --target=arm-linux --disable-threads --enable-languages=c \
163 --prefix=/usr/local/arm/2.95.3 --with-headers=linux-2.4.19/include
171 <heading>Compiling glibc</heading>
173 Depending on your target, you may choose another glibc version (eg: 2.1.3 for linupy 1.4)
175 tar -xvzf glibc-2.2.5.tar.gz
177 tar -xvzf ../glibc-linuxthreads-2.2.5.tar.gz
178 CC=arm-linux-gcc ./configure arm-linux --target=arm-linux \
179 --prefix=/usr/local/arm/2.95.3/arm-linux --enable-add-ons
182 The following step is quite long !
185 CC=arm-linux-gcc make
188 If you have problems compiling glibc due to pread/pwrite, edit <tt>sysdeps/unix/sysv/linux/kernel-features.h</tt>
189 and turn <tt>__ASSUME_PREAD_SYSCALL</tt> and
190 <tt>__ASSUME_PWRITE_SYSCALL</tt> from 1 to 0.
193 CC=arm-linux-gcc make install
198 <heading>Full cross compiler (gcc)</heading>
202 tar -xvzf gcc-2.95.3.tar.gz
203 patch -p1 -d gcc-2.95.3 < gcc-2.95.3.diff
204 patch -p1 -d gcc-2.95.3 < gcc-2.95.3.diff2
206 ./configure --target=arm-linux --prefix=/usr/local/arm/2.95.3
213 <heading>Compiling linux kernel</heading>
216 <heading>Misc</heading>
218 Add <tt>/usr/local/arm/2.95.3/bin</tt> to your PATH. Add the following line (depends on your shell)
219 to your shell's configuration file :
221 export PATH=/usr/local/arm/2.95.3/bin:$PATH
223 I would advise you to completely log out and then log in again, so that
224 the change would be taken into account. You can now check that when you
225 type <tt>arm-linux-gcc</tt>, it launches the cross-compiler.
229 Next are some packages that you may compile by yourself, but I found
230 it was easier to use the precompiled packages. You can take them
231 at <htmlurl url="http://ipkgfind.handhelds.org/" name="ipkgfind">.
232 You may find packages with other version numbers which should not be
235 <tag><tt>libgcc1_3.1.1-1_arm.ipk</tt></tag>
236 This provides libgcc.so.1 which is needed to compile some libraries.
237 <tag><tt>xlibs_4.1-5_arm.ipk</tt>, <tt>xlibs-dev_4.1.0-16_arm.ipk</tt></tag>
238 Those are the libraries ans the development files for X windows.
239 <tag><tt>zlib1g_1.1.4-3_arm.ipk</tt>, <tt>zlib1g-dev_1.1.3-fam1_arm.ipk</tt></tag>
240 These libraries are needed by some libraries to compile.
243 Install these packages on your compiler box in <tt>/usr/local/arm/2.95.3/arm-linux</tt> :
244 You can use the script <tt>install.sh</tt> :
247 # script to install .ipk into the arm-toolchain
248 # usage : ./install.sh foobar.ipk
250 if ! tar -xvzf $1 2> /dev/null
252 ar xv $1 2> /dev/null
254 cp data.tar.gz /usr/local/arm/2.95.3/arm-linux
255 cd /usr/local/arm/2.95.3/arm-linux
256 tar -xvzf data.tar.gz
263 <heading>Setting up Opie cross-compile environment</heading>
264 <p>Download the Opie SDK from the website <htmlurl url="http://opie.handhelds.org/" name="OPIE website">
265 using the menuitem "Download Opie SDK" or try the direct link here: <htmlurl url="ftp://ftp.handhelds.org/zecke/" name="Download Opie SDK">.
266 Download all files to your ${SOURCES}/opie directory.
269 <heading>Opie SDK</heading>
270 <p>The Opie SDK does not come with a README file or installation instructions.
271 I give them here instead. There are two tar files in the download a OpieSDK.tar.gz2 and a kdevelop_src.tar.bz2.
272 The last file is a modified kdevelop for use with the OpieSDK. In this tutorial we will not use that.
273 Unpack OpieSDK.tar.bz2 in your sources <tt>cd ${SOURCES}/opie</tt> directory.
276 tar -xjvf OpieSdk.tar.bz2
278 It creates a directories structure <tt>${SOURCES}/opie/opt/OpieSDK</tt>. Inside that directory a script is present to
279 <tt>start_kdevelop</tt>. Modify this script so that it uses the correct paths for you setup.
282 source ${SOURCES}/opie/opt/OpieSdk/dev_env
284 export KDEDIR=${SOURCES}/opie/opt/OpieSdk/kde
285 export PATH=${SOURCES}/opie/opt/OpieSdk/kde/bin:$PATH
289 Save the script. Do the same with the script <tt>arm_source</tt>
291 source ${SOURCES}/opie/opt/OpieSdk/dev_env
292 export QTDIR=$QTDIR_ARM
293 export OPIEDIR=$OPIEDIR_ARM
295 Save the script and modify the script <tt>host_source</tt> in the same manner as above.
297 source ${SOURCES}/opie/opt/OpieSdk/dev_env
298 export QTDIR=$QTDIR_NAT
299 export OPIEDIR=$OPIEDIR_NAT
301 Save the script and modify the script <tt>dev_env</tt> in the same manner as above.
303 export PYTHONPATH=${SOURCES}/opie/opt/OpieSdk/python/opie:${SOURCES}/opie/opt/OpieSdk/python/sip
304 export PATH=/usr/local/arm/2.95.3/bin:/opt/OpieSdk/host_tools:${SOURCES}/opie/opt/OpieSdk/opie/x86/qt-2.3.7/bin:$PATH
305 export PATH=${SOURCES}/opie/opt/OpieSdk/opie/x86/qmake:$PATH
306 export QTDIR_NAT=${SOURCES}/opie/opt/OpieSdk/opie/x86/qt-2.3.7
307 export OPIEDIR_NAT=${SOURCES}/opie/opt/OpieSdk/opie/x86/sdk
308 export QTDIR_ARM=${SOURCES}/opie/opt/OpieSdk/opie/arm/qt-2.3.7
309 export OPIEDIR_ARM=${SOURCES}/opie/opt/OpieSdk/opie/arm/sdk
310 export OPIE_SDK_BASE=${SOURCES}/opie/opt/OpieSdk/
311 export OPIE_SDK_QMAKE_BASE=${SOURCES}/opie/opt/OpieSdk/opie/x86/sdk/mkspecs/qws/
312 export OPIE_DOC=${SOURCES}/opie/opt/OpieSdk/apidocs
314 export LD_LIBRARY_PATH=${SOURCES}/opie/opt/OpieSdk/sip/lib:$OPIEDIR_NAT/lib:$QTDIR_NAT/lib:$LD_LIBRARY_PATH
315 export OPIE_LANGUAGES=de:en:cz:da:dk:es:fr:hu:it:ja:ko:lv:mk:nl:no:pl:pt:pt_BR:ru:sl:zh_CN:zh_TW
317 The symbolic linke to the tool <tt>qmake</tt> points now to the wrong place. We need to fix this symbolic link.
318 Here is the way to do that.
321 ln -sf /home/jpsaman/src/opie/opt/OpieSdk/opie/x86/sdk/qmake/qmake qmake
324 Now it is time to fire up our development environment and start hacking in Opie.
330 <heading>Cross compiling libraries needed by vlc</heading>
332 Download <tt>ipaq-config.site</tt> to ${SOURCES}.
333 When downloading source tarballs copy them to your ${SOURCES} directory.
334 Each section is supposed to begin with <tt>cd ${SOURCES}</tt>.
337 <heading>SDL</heading>
339 It is not clean at all but did not found a better working method.
341 it compiles well, but when linking with vlc there are problems !
344 <tt>/usr/local/arm/2.95.3/arm-linux/bin</tt> should contain the cross
345 compiler without the prefix <tt>arm-linux-</tt>.
348 tar -xvzf SDL-1.2.5.tar.gz
350 ./configure --enable-release --target=arm-linux --host=arm-linux \
352 --prefix=/usr/local/arm/2.95.3/arm-linux/usr \
353 --x-includes=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/include \
354 --x-libraries=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/lib \
355 --disable-video-opengl
357 export PATH=/usr/local/arm/2.95.3/arm-linux/bin:$PATH
364 <heading>Glib/GTK+</heading>
367 tar -xvzf glib-1.2.10.tar.gz
369 CONFIG_SITE=../ipaq-config.site ./configure \
370 --prefix=/usr/local/arm/2.95.3/arm-linux/usr
374 tar -xvzf gtk+-1.2.10.tar.gz
376 CONFIG_SITE=../ipaq-config.site ./configure \
377 --prefix=/usr/local/arm/2.95.3/arm-linux/usr --with-glib=../glib-1.2.10
384 <heading>ffmpeg</heading>
387 tar -xvzf ffmpeg.tar.gz
389 ./configure --cpu=armv4l --cc=arm-linux-gcc --disable-mmx \
390 --prefix=/usr/local/arm/2.95.3/arm-linux/usr --enable-shared
395 Vlc does not require that you install ffmpeg.
399 <heading>mad</heading>
402 tar -xvzf mad-0.14.2b.tar.gz
404 ./configure --enable-release --target=arm-linux --host=arm-linux \
406 --prefix=/usr/local/arm/2.95.3/arm-linux/usr \
407 --x-includes=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/include \
408 --x-libraries=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/lib \
409 --disable-video-opengl
410 export PATH=/usr/local/arm/2.95.3/arm-linux/bin:$PATH
416 <heading>gpe</heading>
419 <heading>tremor</heading>
421 Tremor is an integer decoder for the vorbis audio codec. Download the
422 source through CVS at the <htmlurl url="http://www.xiph.org/" name="xiph.org"> website.
425 Log into CVS using the password : <tt>anoncvs</tt>.
427 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot login
428 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co Tremor
430 CONFIG_SITE=../ipaq-config.site ./configure \
431 --prefix=/usr/local/arm/2.95.3/arm-linux/usr
437 <heading>ogg</heading>
439 For ogg, it is the same as Tremor.
441 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot login
442 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co ogg
444 CONFIG_SITE=../ipaq-config.site ./configure \
445 --prefix=/usr/local/arm/2.95.3/arm-linux/usr
451 <heading>flac</heading>
454 tar -xvzf flac-1.1.0.tar.gz
456 ./configure --enable-release --host=arm-linux --target=arm-linux \
457 --prefix=/usr/local/arm/2.95.3/arm-linux/usr
459 It will probably fail (due to the xmms plugin), but it is not a problem,
460 we will continue installation by hand.
462 cp -Rf include/FLAC /usr/local/arm/2.95.3/arm-linux/include
469 <heading>libdvbpsi</heading>
472 tar -xvzf libdvbpsi-0.1.2.tar.gz
475 ./configure --target=arm-linux --host=arm-linux
481 <heading>a52</heading>
484 tar -xvzf a52dec-0.7.4.tar.gz
486 ./configure --enable-release --host=arm-linux --target=arm-linux \
487 --prefix=/usr/local/arm/2.95.3/arm-linux/usr
495 <heading>Cross compiling vlc itself</heading>
497 First of all, run the <tt>./bootstrap</tt> script.
498 Then run one of the <tt>ipkg/rules.*</tt>, according to what you want to compile.
499 Finally you just have to type make and you'll get a stand alone vlc.
502 Run <tt>arm-linux-strip</tt> to remove symbols and so the size of the file,
503 and now you can test it easily on your PDA.
511 </article></linuxdoc>