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
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
265 <heading>Cross compiling libraries needed by vlc</heading>
267 Download <tt>ipaq-config.site</tt> to ${SOURCES}.
268 When downloading source tarballs copy them to your ${SOURCES} directory.
269 Each section is supposed to begin with <tt>cd ${SOURCES}</tt>.
272 <heading>SDL</heading>
274 It is not clean at all but did not found a better working method.
276 it compiles well, but when linking with vlc there are problems !
279 <tt>/usr/local/arm/2.95.3/arm-linux/bin</tt> should contain the cross
280 compiler without the prefix <tt>arm-linux-</tt>.
283 tar xvzf SDL-1.2.5.tar.gz
285 ./configure --enable-release --target=arm-linux --host=arm-linux \
287 --prefix=/usr/local/arm/2.95.3/arm-linux/usr \
288 --x-includes=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/include \
289 --x-libraries=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/lib \
290 --disable-video-opengl
292 export PATH=/usr/local/arm/2.95.3/arm-linux/bin:$PATH
299 <heading>Glib/GTK+</heading>
302 tar xvzf glib-1.2.10.tar.gz
304 CONFIG_SITE=../ipaq-config.site ./configure \
305 --prefix=/usr/local/arm/2.95.3/arm-linux/usr
309 tar xvzf gtk+-1.2.10.tar.gz
311 CONFIG_SITE=../ipaq-config.site ./configure \
312 --prefix=/usr/local/arm/2.95.3/arm-linux/usr --with-glib=../glib-1.2.10
319 <heading>ffmpeg</heading>
322 tar xvzf ffmpeg.tar.gz
324 ./configure --cpu=armv4l --cc=arm-linux-gcc --disable-mmx \
325 --prefix=/usr/local/arm/2.95.3/arm-linux/usr --enable-shared
330 Vlc does not require that you install ffmpeg.
334 <heading>mad</heading>
337 tar xvzf mad-0.14.2b.tar.gz
339 ./configure --enable-release --target=arm-linux --host=arm-linux \
341 --prefix=/usr/local/arm/2.95.3/arm-linux/usr \
342 --x-includes=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/include \
343 --x-libraries=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/lib \
344 --disable-video-opengl
345 export PATH=/usr/local/arm/2.95.3/arm-linux/bin:$PATH
351 <heading>gpe</heading>
354 <heading>tremor</heading>
356 Tremor is an integer decoder for the vorbis audio codec. Download the
357 source through CVS at the <htmlurl url="http://www.xiph.org" name="xiph.org"> website.
360 Log into CVS using the password : <tt>anoncvs</tt>.
362 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot login
363 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co Tremor
365 CONFIG_SITE=../ipaq-config.site ./configure \
366 --prefix=/usr/local/arm/2.95.3/arm-linux/usr
372 <heading>ogg</heading>
374 For ogg, it is the same as Tremor.
376 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot login
377 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co ogg
379 CONFIG_SITE=../ipaq-config.site ./configure \
380 --prefix=/usr/local/arm/2.95.3/arm-linux/usr
386 <heading>flac</heading>
389 tar xvzf flac-1.1.0.tar.gz
391 ./configure --enable-release --host=arm-linux --target=arm-linux \
392 --prefix=/usr/local/arm/2.95.3/arm-linux/usr
394 It will probably fail (due to the xmms plugin), but it is not a problem,
395 we will continue installation by hand.
397 cp -Rf include/FLAC /usr/local/arm/2.95.3/arm-linux/include
404 <heading>libdvbpsi</heading>
407 tar xvzf libdvbpsi-0.1.2.tar.gz
410 ./configure --target=arm-linux --host=arm-linux
416 <heading>a52</heading>
419 tar xvzf a52dec-0.7.4.tar.gz
421 ./configure --enable-release --host=arm-linux --target=arm-linux \
422 --prefix=/usr/local/arm/2.95.3/arm-linux/usr
430 <heading>Cross compiling vlc itself</heading>
432 First of all, run the <tt>./bootstrap</tt> script.
433 Then run one of the <tt>ipkg/rules.*</tt>, according to what you want to compile.
434 Finally you just have to type make and you'll get a stand alone vlc.
437 Run <tt>arm-linux-strip</tt> to remove symbols and so the size of the file,
438 and now you can test it easily on your PDA.
445 </article></linuxdoc>