]> git.sesse.net Git - vlc/blob - doc/arm-crosscompile-howto.sgml
.
[vlc] / doc / arm-crosscompile-howto.sgml
1 <!doctype linuxdoc system>
2 <linuxdoc><article>
3 <titlepag>
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   <author>Jean-Paul Saman <tt><htmlurl url="mailto:jpsaman@wxs.nl" name="<jpsaman@wxs.nl>"></tt></author>
7   <date>v0.0.2, 19 march 2004</date>
8   <abstract>
9     This document describes all the steps to cross compile vlc for ARM based
10     platforms. It describes how to build a cross compilation toolchain, how to
11     build the libraries needed by vlc and the compilation of the vlc itself.
12   </abstract>
13 </titlepag>
14
15 <toc>
16
17 <sect>
18   <heading>Introduction</heading>
19   <p>
20   This document is only a first draft. It does not intend to cover all the 
21   subject. You may still have some problems at some steps or find better 
22   way to do them. If you have any comment do not hesitate to contact us.
23   </p>
24   <sect1>
25     <heading>Which platforms are targeted ?</heading>
26     <p>
27       I will describe here how to compile vlc for an ARM based
28       PDA running linux. It includes for example :
29       <itemize>
30       <item>Compaq - iPaq (H36xx, H38xx,...), using Familiar Linux
31         <itemize>
32           <item>GNU Portable Environment (GPE)
33           <item>Opie
34         </itemize>
35       </item>
36       <item>YOPY/Linupy</item>
37       <item>Zaurus</item>
38       </itemize>
39     </p>
40   </sect1> 
41   <sect1>
42     <heading>Requirements for cross-compilation</heading>
43   </sect1>
44   <sect1>
45     <heading>Why cross-compiling ?</heading>
46     <p>
47       It is of course possible to compile directly on the targeted platform.
48       But there are a lot of great advantages to cross-compile :
49       <itemize>
50       <item>The most important one is probably the speed, because a
51         desktop computer is most of the time faster than a PDA for
52         compilation.</item>
53       <item>Another big problem is that a complete compilation toolchain
54         does take a great amount of disk space. And this space is usually
55         very limited on embedded systems.</item>
56       <item>And there also may not be enough memory to compile big files.</item>
57       </itemize>
58     </p>
59   </sect1>
60 </sect>
61
62 <sect>
63   <heading>Building the toolchain</heading>
64   <sect1>
65     <heading>Prerequisite</heading>
66     <sect2>
67       <heading>Importants paths</heading>
68       <p>
69         During this section, we will use the following paths :
70       </p>
71       <p>I would personally advise to compile everything as a normal user and
72       then install everything as root.</p>
73       <sect3>
74         <heading>${SRCDIR}</heading>
75         <p>
76         This is where the sources will be located and where the compilation
77         will be done.
78         (eg: <tt>/usr/src</tt> or <tt>/home/foobar/arm-src</tt>).
79         </p>
80       </sect3>
81       <sect3>
82         <heading>${PREFIX}</heading>
83         <p>This is where you want to install your cross compilation toolchain.
84         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
85         to be done as <tt>root</tt>.
86         Or it can be installed in user-land, for the user's own use (<tt>/home/foobar/arm/2.95.3</tt> for example).
87         In this paper, the chosen prefix is <tt>/usr/local/arm/2.95.3</tt>,
88         you will have to adapt the commands to what you choose..
89         </p>
90       </sect3>
91     </sect2>
92     <sect2>
93       <heading>Files needed</heading>
94       <p>Download the following files and put them in the <bf>${SRCDIR}</bf>.
95       Most of them are available on the <htmlurl url="http://www.videolan.org/vlc/download-sources.html" name="VideoLAN website">.
96         <itemize>
97           <item><tt>binutils-2.11.2.tar.gz</tt></item>
98           <item><tt>linux-2.4.19.tar.bz2</tt></item>
99           <item><tt>patch-2.4.19-rmk4.bz2</tt></item>
100           <item><tt>gcc-2.95.3.tar.gz</tt></item>
101           <item><tt>gcc-2.95.3.diff.bz2</tt></item>
102           <item><tt>gcc-2.95.3.diffbis.bz2</tt></item>
103           <item><tt>gcc-2.95.3.diff2</tt></item>
104           <item><tt>glibc-2.2.5.tar.gz</tt></item>
105           <item><tt>glibc-linuxthreads-2.2.5.tar.gz</tt></item>
106           <item><tt>SDL-1.2.5.tar.gz</tt></item>
107           <item><tt>glib-1.2.10.tar.gz</tt></item>
108           <item><tt>ffmpeg.tar.gz</tt></item>
109           <item><tt>mad-0.14.2b.tar.gz</tt></item>
110           <item><tt>flac-1.1.0.tar.gz</tt></item>
111           <item><tt>libdvbpsi-0.1.2.tar.gz</tt></item>
112           <item><tt>a52dec-0.7.4.tar.gz</tt></item>
113         </itemize>
114       </p>
115     </sect2>
116   </sect1>
117   <sect1>
118     <heading>Binutils</heading>
119     <p>Compiling binutils is pretty simple :
120     <tscreen><verb>
121 tar -xzf binutils-2.11.2.tar.gz
122 cd binutils-2.11.2
123 ./configure --target=arm-linux --prefix=/usr/local/arm/2.95.3
124 make
125 make install
126     </verb></tscreen>
127     </p>
128   </sect1>
129   <sect1>
130     <heading>Preparing linux kernel</heading>
131     <p>
132     <tscreen><verb>
133 tar -xzf linux-2.4.19.tar.bz2
134 bunzip2 patch-2.4.19-rmk4.bz2
135 cd linux-2.4.19
136 patch -p1 &lt; ../patch-2.4.19-rmk4.bz2
137 make clean ARCH=arm CROSS_COMPILE=arm-linux-
138 make ARCH=arm h3600_config
139   </verb></tscreen>
140   <bf>Do not forget</bf> to save the configuration even if no changes 
141   are made !
142   <tscreen><verb>
143 make ARCH=arm menuconfig
144 make symlinks ARCH=arm CROSS_COMPILE=arm-linux-
145 mkdir -p /usr/local/arm/2.95.3/arm-linux/include
146 cp -Rf include/asm include/asm-arm include/linux \
147                       /usr/local/arm/2.95.3/arm-linux/include
148 cd /usr/local/arm/2.95.3/arm-linux
149 ln -s include sys-linux
150     </verb></tscreen>
151     </p>
152   </sect1>
153   <sect1>
154     <heading>Basic cross compiler (gcc)</heading>
155     <p>
156     <tscreen><verb>
157 tar -xvzf gcc-2.95.3.tar.gz
158 bunzip2 gcc-2.95.3.diff.bz2
159 bunzip2 gcc-2.95.3.diffbis.bz2
160 patch -p1 -d gcc-2.95.3 &lt; gcc-2.95.3.diff
161 patch -p1 -d gcc-2.95.3 &lt; gcc-2.95.3.diffbis
162 cd gcc-2.95.3
163 ./configure --target=arm-linux --disable-threads --enable-languages=c \
164         --prefix=/usr/local/arm/2.95.3 --with-headers=linux-2.4.19/include
165 make
166 make install
167     </verb></tscreen>
168     </p>
169
170   </sect1>
171   <sect1>
172     <heading>Compiling glibc</heading>
173     <p>
174     Depending on your target, you may choose another glibc version (eg: 2.1.3 for linupy 1.4)
175     <tscreen><verb>
176 tar -xvzf glibc-2.2.5.tar.gz
177 cd glibc-2.2.5
178 tar -xvzf ../glibc-linuxthreads-2.2.5.tar.gz
179 CC=arm-linux-gcc ./configure arm-linux --target=arm-linux \
180           --prefix=/usr/local/arm/2.95.3/arm-linux --enable-add-ons
181     </verb></tscreen>
182
183 The following step is quite long !
184
185     <tscreen><verb>
186 CC=arm-linux-gcc make
187     </verb></tscreen>
188
189 If you have problems compiling glibc due to pread/pwrite, edit <tt>sysdeps/unix/sysv/linux/kernel-features.h</tt>
190 and turn <tt>__ASSUME_PREAD_SYSCALL</tt> and 
191 <tt>__ASSUME_PWRITE_SYSCALL</tt> from 1 to 0.
192
193     <tscreen><verb>
194 CC=arm-linux-gcc make install
195     </verb></tscreen>
196     </p>
197   </sect1>
198   <sect1>
199     <heading>Full cross compiler (gcc)</heading>
200     <p>
201     <tscreen><verb>
202 rm -Rf gcc-2.95.3
203 tar -xvzf gcc-2.95.3.tar.gz
204 patch -p1 -d gcc-2.95.3 &lt; gcc-2.95.3.diff
205 patch -p1 -d gcc-2.95.3 &lt; gcc-2.95.3.diff2
206 cd gcc-2.95.3
207 ./configure --target=arm-linux --prefix=/usr/local/arm/2.95.3
208 make
209 make install
210     </verb></tscreen>
211     </p>
212   </sect1>
213   <sect1>
214     <heading>Compiling linux kernel</heading>
215   </sect1>
216   <sect1>
217     <heading>Misc</heading>
218     <p>
219     Add <tt>/usr/local/arm/2.95.3/bin</tt> to your PATH. Add the following line (depends on your shell)
220     to your shell's configuration file :
221     <tscreen><verb>
222 export PATH=/usr/local/arm/2.95.3/bin:$PATH
223     </verb></tscreen>
224     I would advise you to completely log out and then log in again, so that
225     the change would be taken into account. You can now check that when you
226     type <tt>arm-linux-gcc</tt>, it launches the cross-compiler.
227     </p>
228
229     <p>
230     Next are some packages that you may compile by yourself, but I found
231     it was easier to use the precompiled packages. You can take them
232     at <htmlurl url="http://ipkgfind.handhelds.org/" name="ipkgfind">.
233     You may find packages with other version numbers which should not be
234     a problem.
235     <descrip>
236     <tag><tt>libgcc1_3.1.1-1_arm.ipk</tt></tag>
237         This provides libgcc.so.1 which is needed to compile some libraries.
238     <tag><tt>xlibs_4.1-5_arm.ipk</tt>, <tt>xlibs-dev_4.1.0-16_arm.ipk</tt></tag>
239         Those are the libraries ans the development files for X windows.
240     <tag><tt>zlib1g_1.1.4-3_arm.ipk</tt>, <tt>zlib1g-dev_1.1.3-fam1_arm.ipk</tt></tag>
241         These libraries are needed by some libraries to compile.
242     </descrip>
243     
244     Install these packages on your compiler box in <tt>/usr/local/arm/2.95.3/arm-linux</tt> :
245      You can use the script <tt>install.sh</tt> :
246     <tscreen><verb>
247 #!/bin/sh
248 # script to install .ipk into the arm-toolchain
249 # usage : ./install.sh foobar.ipk
250
251 if ! tar -xvzf $1 2> /dev/null
252 then
253     ar xv $1 2> /dev/null
254 fi
255 cp data.tar.gz /usr/local/arm/2.95.3/arm-linux
256 cd /usr/local/arm/2.95.3/arm-linux
257 tar -xvzf data.tar.gz
258     </verb></tscreen>
259     </p>
260   </sect1>
261 </sect>
262
263 <sect>
264   <heading>Setting up Opie cross-compile environment</heading>
265   <p>Download the Opie SDK from the website <htmlurl url="http://opie.handhelds.org/" name="OPIE website">
266 using the menuitem "Download Opie SDK" or try the direct link here: <htmlurl url="ftp://ftp.handhelds.org/zecke/" name="Download Opie SDK">.
267 Download all files to your ${SOURCES}/opie directory.
268   </p>
269   <sect1>
270     <heading>Opie SDK</heading>
271     <p>The Opie SDK does not come with a README file or installation instructions.
272 I give them here instead. There are two tar files in the download a OpieSDK.tar.gz2 and a kdevelop_src.tar.bz2.
273 The last file is a modified kdevelop for use with the OpieSDK. In this tutorial we will not use that.
274 Unpack OpieSDK.tar.bz2 in your sources <tt>cd ${SOURCES}/opie</tt> directory.
275     <tscreen><verb>
276 cd ${SOURCES}/opie
277 tar -xjvf OpieSdk.tar.bz2
278     </verb></tscreen>
279     It creates a directories structure <tt>${SOURCES}/opie/opt/OpieSDK</tt>. Inside that directory a script is present to
280 <tt>start_kdevelop</tt>. Modify this script so that it uses the correct paths for you setup.
281     <tscreen><verb>
282 #!/bin/sh
283 source ${SOURCES}/opie/opt/OpieSdk/dev_env
284
285 export KDEDIR=${SOURCES}/opie/opt/OpieSdk/kde
286 export PATH=${SOURCES}/opie/opt/OpieSdk/kde/bin:$PATH
287 kbuildsycoca
288 kdevelop
289     </verb></tscreen>
290     Save the script. Do the same with the script <tt>arm_source</tt>
291     <tscreen><verb>
292 source ${SOURCES}/opie/opt/OpieSdk/dev_env
293 export QTDIR=$QTDIR_ARM
294 export OPIEDIR=$OPIEDIR_ARM
295     </verb></tscreen>
296     Save the script and modify the script <tt>host_source</tt> in the same manner as above.
297     <tscreen><verb>
298 source ${SOURCES}/opie/opt/OpieSdk/dev_env
299 export QTDIR=$QTDIR_NAT
300 export OPIEDIR=$OPIEDIR_NAT
301     </verb></tscreen>
302     Save the script and modify the script <tt>dev_env</tt> in the same manner as above.
303     <tscreen><verb>
304 export PYTHONPATH=${SOURCES}/opie/opt/OpieSdk/python/opie:${SOURCES}/opie/opt/OpieSdk/python/sip
305 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
306 export PATH=${SOURCES}/opie/opt/OpieSdk/opie/x86/qmake:$PATH
307 export QTDIR_NAT=${SOURCES}/opie/opt/OpieSdk/opie/x86/qt-2.3.7
308 export OPIEDIR_NAT=${SOURCES}/opie/opt/OpieSdk/opie/x86/sdk
309 export QTDIR_ARM=${SOURCES}/opie/opt/OpieSdk/opie/arm/qt-2.3.7
310 export OPIEDIR_ARM=${SOURCES}/opie/opt/OpieSdk/opie/arm/sdk
311 export OPIE_SDK_BASE=${SOURCES}/opie/opt/OpieSdk/
312 export OPIE_SDK_QMAKE_BASE=${SOURCES}/opie/opt/OpieSdk/opie/x86/sdk/mkspecs/qws/
313 export OPIE_DOC=${SOURCES}/opie/opt/OpieSdk/apidocs
314
315 export LD_LIBRARY_PATH=${SOURCES}/opie/opt/OpieSdk/sip/lib:$OPIEDIR_NAT/lib:$QTDIR_NAT/lib:$LD_LIBRARY_PATH
316 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     </verb></tscreen>
318     The symbolic linke to the tool <tt>qmake</tt> points now to the wrong place. We need to fix this symbolic link.
319 Here is the way to do that.
320     <tscreen><verb>
321 cd host_tools
322 ln -sf /home/jpsaman/src/opie/opt/OpieSdk/opie/x86/sdk/qmake/qmake qmake
323 cd ../
324     </verb></tscreen>
325     Now it is time to fire up our development environment and start hacking in Opie.
326     </p>
327   </sect1>
328 </sect>
329
330 <sect>
331   <heading>Cross compiling libraries needed by vlc</heading>
332   <p>
333   Download <tt>ipaq-config.site</tt> to ${SOURCES}.
334   When downloading source tarballs copy them to your ${SOURCES} directory.
335   Each section is supposed to begin with <tt>cd ${SOURCES}</tt>.
336   </p>
337   <sect1>
338     <heading>SDL</heading>
339     <p>
340     It is not clean at all but did not found a better working method.
341     Using config.site
342     it compiles well, but when linking with vlc there are problems !
343     </p>
344     <p>
345     <tt>/usr/local/arm/2.95.3/arm-linux/bin</tt> should contain the cross 
346     compiler without the prefix <tt>arm-linux-</tt>.
347     
348     <tscreen><verb>
349 tar -xvzf SDL-1.2.5.tar.gz
350 cd SDL-1.2.5
351 ./configure --enable-release --target=arm-linux --host=arm-linux \
352       --disable-esd \
353       --prefix=/usr/local/arm/2.95.3/arm-linux/usr \
354       --x-includes=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/include \
355       --x-libraries=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/lib \
356       --disable-video-opengl
357
358 export PATH=/usr/local/arm/2.95.3/arm-linux/bin:$PATH
359
360 make && make install
361     </verb></tscreen>
362     </p>
363   </sect1>
364   <sect1>
365     <heading>Glib/GTK+</heading>
366     <p>
367     <tscreen><verb>
368 tar -xvzf glib-1.2.10.tar.gz
369 cd glib-1.2.10
370 CONFIG_SITE=../ipaq-config.site ./configure \
371       --prefix=/usr/local/arm/2.95.3/arm-linux/usr
372 make
373 make install
374 cd ..
375 tar -xvzf gtk+-1.2.10.tar.gz
376 cd gtk+-1.2.10
377 CONFIG_SITE=../ipaq-config.site ./configure \
378       --prefix=/usr/local/arm/2.95.3/arm-linux/usr --with-glib=../glib-1.2.10
379 make 
380 make install
381     </verb></tscreen>
382     </p>
383   </sect1>
384   <sect1>
385     <heading>ffmpeg</heading>
386     <p>
387     <tscreen><verb>
388 tar -xvzf ffmpeg.tar.gz
389 cd ffmpeg
390 ./configure --cpu=armv4l --cc=arm-linux-gcc --disable-mmx \
391         --prefix=/usr/local/arm/2.95.3/arm-linux/usr --enable-shared
392 cd libavcodec
393 make
394     </verb></tscreen>
395
396     Vlc does not require that you install ffmpeg.
397     </p>
398   </sect1>
399   <sect1>
400     <heading>mad</heading>
401     <p>
402     <tscreen><verb>
403 tar -xvzf mad-0.14.2b.tar.gz
404 cd mad-0.14.2b
405 ./configure --enable-release --target=arm-linux --host=arm-linux \
406       --disable-esd \
407       --prefix=/usr/local/arm/2.95.3/arm-linux/usr \
408       --x-includes=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/include \
409       --x-libraries=/usr/local/arm/2.95.3/arm-linux/usr/X11R6/lib \
410       --disable-video-opengl
411 export PATH=/usr/local/arm/2.95.3/arm-linux/bin:$PATH
412 make
413     </verb></tscreen>
414     </p>
415   </sect1>
416   <sect1>
417     <heading>gpe</heading>
418   </sect1>
419   <sect1>
420     <heading>tremor</heading>
421     <p>
422     Tremor is an integer decoder for the vorbis audio codec. Download the
423     source through CVS at the <htmlurl url="http://www.xiph.org/" name="xiph.org"> website.
424     </p>
425     <p>
426     Log into CVS using the password : <tt>anoncvs</tt>.
427     <tscreen><verb>
428 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot login
429 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co Tremor
430 cd Tremor
431 CONFIG_SITE=../ipaq-config.site ./configure \
432               --prefix=/usr/local/arm/2.95.3/arm-linux/usr
433 make
434 </verb></tscreen>
435     </p>
436   </sect1>
437   <sect1>
438     <heading>ogg</heading>
439     <p>
440     For ogg, it is the same as Tremor.
441     <tscreen><verb>
442 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot login
443 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co ogg
444 cd ogg
445 CONFIG_SITE=../ipaq-config.site ./configure \
446              --prefix=/usr/local/arm/2.95.3/arm-linux/usr
447 make
448     </verb></tscreen>
449     </p>
450   </sect1>
451   <sect1>
452     <heading>flac</heading>
453     <p>
454     <tscreen><verb>
455 tar -xvzf flac-1.1.0.tar.gz
456 cd flac-1.1.0
457 ./configure --enable-release --host=arm-linux --target=arm-linux \
458             --prefix=/usr/local/arm/2.95.3/arm-linux/usr
459     </verb></tscreen>
460     It will probably fail (due to the xmms plugin), but it is not a problem, 
461     we will continue installation by hand.
462     <tscreen><verb>
463 cp -Rf include/FLAC /usr/local/arm/2.95.3/arm-linux/include
464 cd src/libFLAC
465 make install
466     </verb></tscreen>
467     </p>
468   </sect1>
469   <sect1>
470     <heading>libdvbpsi</heading>
471     <p>
472     <tscreen><verb>
473 tar -xvzf libdvbpsi-0.1.2.tar.gz
474 cd libdvbpsi-0.1.2
475 ./bootstrap
476 ./configure --target=arm-linux --host=arm-linux
477 make
478     </verb></tscreen>
479     </p>
480   </sect1>
481   <sect1>
482     <heading>a52</heading>
483     <p>
484     <tscreen><verb>
485 tar -xvzf a52dec-0.7.4.tar.gz
486 cd a52dec-0.7.4
487 ./configure --enable-release --host=arm-linux --target=arm-linux \
488             --prefix=/usr/local/arm/2.95.3/arm-linux/usr
489 make && make install
490     </verb></tscreen>
491     </p>
492   </sect1>
493 </sect>
494
495 <sect>
496   <heading>Cross compiling vlc itself</heading>
497   <p>
498   First of all, run the <tt>./bootstrap</tt> script.
499   Then run one of the <tt>ipkg/rules.*</tt>, according to what you want to compile.
500   Finally you just have to type make and you'll get a stand alone vlc.
501   </p>
502   <p>
503   Run <tt>arm-linux-strip</tt> to remove symbols and so the size of the file,
504   and now you can test it easily on your PDA.
505   </p>
506   <p>
507     Enjoy !
508   </p>
509 </sect>
510
511
512 </article></linuxdoc>