]> git.sesse.net Git - vlc/blob - doc/arm-crosscompile-howto.sgml
Added a section about Opie SDK kit.
[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   <date>v0.0.1, 13 march 2003</date>
7   <abstract>
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.
11   </abstract>
12 </titlepag>
13
14 <toc>
15
16 <sect>
17   <heading>Introduction</heading>
18   <p>
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.
22   </p>
23   <sect1>
24     <heading>Which platforms are targeted ?</heading>
25     <p>
26       I will describe here how to compile vlc for an ARM based
27       PDA running linux. It includes for example :
28       <itemize>
29       <item>Compaq - iPaq (H36xx, H38xx,...), using Familiar Linux
30         <itemize>
31           <item>GNU Portable Environment (GPE)
32           <item>Opie
33         </itemize>
34       </item>
35       <item>YOPY/Linupy</item>
36       <item>Zaurus</item>
37       </itemize>
38     </p>
39   </sect1> 
40   <sect1>
41     <heading>Requirements for cross-compilation</heading>
42   </sect1>
43   <sect1>
44     <heading>Why cross-compiling ?</heading>
45     <p>
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 :
48       <itemize>
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
51         compilation.</item>
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>
56       </itemize>
57     </p>
58   </sect1>
59 </sect>
60
61 <sect>
62   <heading>Building the toolchain</heading>
63   <sect1>
64     <heading>Prerequisite</heading>
65     <sect2>
66       <heading>Importants paths</heading>
67       <p>
68         During this section, we will use the following paths :
69       </p>
70       <p>I would personally advise to compile everything as a normal user and
71       then install everything as root.</p>
72       <sect3>
73         <heading>${SRCDIR}</heading>
74         <p>
75         This is where the sources will be located and where the compilation
76         will be done.
77         (eg: <tt>/usr/src</tt> or <tt>/home/foobar/arm-src</tt>).
78         </p>
79       </sect3>
80       <sect3>
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..
88         </p>
89       </sect3>
90     </sect2>
91     <sect2>
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">.
95         <itemize>
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>
112         </itemize>
113       </p>
114     </sect2>
115   </sect1>
116   <sect1>
117     <heading>Binutils</heading>
118     <p>Compiling binutils is pretty simple :
119     <tscreen><verb>
120 tar -xzf binutils-2.11.2.tar.gz
121 cd binutils-2.11.2
122 ./configure --target=arm-linux --prefix=/usr/local/arm/2.95.3
123 make
124 make install
125     </verb></tscreen>
126     </p>
127   </sect1>
128   <sect1>
129     <heading>Preparing linux kernel</heading>
130     <p>
131     <tscreen><verb>
132 tar -xzf linux-2.4.19.tar.bz2
133 bunzip2 patch-2.4.19-rmk4.bz2
134 cd linux-2.4.19
135 patch -p1 &lt; ../patch-2.4.19-rmk4.bz2
136 make clean ARCH=arm CROSS_COMPILE=arm-linux-
137 make ARCH=arm h3600_config
138   </verb></tscreen>
139   <bf>Do not forget</bf> to save the configuration even if no changes 
140   are made !
141   <tscreen><verb>
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
149     </verb></tscreen>
150     </p>
151   </sect1>
152   <sect1>
153     <heading>Basic cross compiler (gcc)</heading>
154     <p>
155     <tscreen><verb>
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 &lt; gcc-2.95.3.diff
160 patch -p1 -d gcc-2.95.3 &lt; gcc-2.95.3.diffbis
161 cd gcc-2.95.3
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
164 make
165 make install
166     </verb></tscreen>
167     </p>
168
169   </sect1>
170   <sect1>
171     <heading>Compiling glibc</heading>
172     <p>
173     Depending on your target, you may choose another glibc version (eg: 2.1.3 for linupy 1.4)
174     <tscreen><verb>
175 tar -xvzf glibc-2.2.5.tar.gz
176 cd glibc-2.2.5
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
180     </verb></tscreen>
181
182 The following step is quite long !
183
184     <tscreen><verb>
185 CC=arm-linux-gcc make
186     </verb></tscreen>
187
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.
191
192     <tscreen><verb>
193 CC=arm-linux-gcc make install
194     </verb></tscreen>
195     </p>
196   </sect1>
197   <sect1>
198     <heading>Full cross compiler (gcc)</heading>
199     <p>
200     <tscreen><verb>
201 rm -Rf gcc-2.95.3
202 tar -xvzf gcc-2.95.3.tar.gz
203 patch -p1 -d gcc-2.95.3 &lt; gcc-2.95.3.diff
204 patch -p1 -d gcc-2.95.3 &lt; gcc-2.95.3.diff2
205 cd gcc-2.95.3
206 ./configure --target=arm-linux --prefix=/usr/local/arm/2.95.3
207 make
208 make install
209     </verb></tscreen>
210     </p>
211   </sect1>
212   <sect1>
213     <heading>Compiling linux kernel</heading>
214   </sect1>
215   <sect1>
216     <heading>Misc</heading>
217     <p>
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 :
220     <tscreen><verb>
221 export PATH=/usr/local/arm/2.95.3/bin:$PATH
222     </verb></tscreen>
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.
226     </p>
227
228     <p>
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
233     a problem.
234     <descrip>
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.
241     </descrip>
242     
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> :
245     <tscreen><verb>
246 #!/bin/sh
247 # script to install .ipk into the arm-toolchain
248 # usage : ./install.sh foobar.ipk
249
250 if ! tar -xvzf $1 2> /dev/null
251 then
252     ar xv $1 2> /dev/null
253 fi
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
257     </verb></tscreen>
258     </p>
259   </sect1>
260 </sect>
261
262 <sect>
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.
267   </p>
268   <sect1>
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.
274     <tscreen><verb>
275 cd ${SOURCES}/opie
276 tar -xjvf OpieSdk.tar.bz2
277     </verb></tscreen>
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.
280     <tscreen><verb>
281 #!/bin/sh
282 source ${SOURCES}/opie/opt/OpieSdk/dev_env
283
284 export KDEDIR=${SOURCES}/opie/opt/OpieSdk/kde
285 export PATH=${SOURCES}/opie/opt/OpieSdk/kde/bin:$PATH
286 kbuildsycoca
287 kdevelop
288     </verb></tscreen>
289     Save the script. Do the same with the script <tt>arm_source</tt>
290     <tscreen><verb>
291 source ${SOURCES}/opie/opt/OpieSdk/dev_env
292 export QTDIR=$QTDIR_ARM
293 export OPIEDIR=$OPIEDIR_ARM
294     </verb></tscreen>
295     Save the script and modify the script <tt>host_source</tt> in the same manner as above.
296     <tscreen><verb>
297 source ${SOURCES}/opie/opt/OpieSdk/dev_env
298 export QTDIR=$QTDIR_NAT
299 export OPIEDIR=$OPIEDIR_NAT
300     </verb></tscreen>
301     Save the script and modify the script <tt>dev_env</tt> in the same manner as above.
302     <tscreen><verb>
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
313
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
316     </verb></tscreen>
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.
319     <tscreen><verb>
320 cd host_tools
321 ln -sf /home/jpsaman/src/opie/opt/OpieSdk/opie/x86/sdk/qmake/qmake qmake
322 cd ../
323     </verb></tscreen>
324     Now it is time to fire up our development environment and start hacking in Opie.
325     </p>
326   </sect1>
327 </sect>
328
329 <sect>
330   <heading>Cross compiling libraries needed by vlc</heading>
331   <p>
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>.
335   </p>
336   <sect1>
337     <heading>SDL</heading>
338     <p>
339     It is not clean at all but did not found a better working method.
340     Using config.site
341     it compiles well, but when linking with vlc there are problems !
342     </p>
343     <p>
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>.
346     
347     <tscreen><verb>
348 tar -xvzf SDL-1.2.5.tar.gz
349 cd SDL-1.2.5
350 ./configure --enable-release --target=arm-linux --host=arm-linux \
351       --disable-esd \
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
356
357 export PATH=/usr/local/arm/2.95.3/arm-linux/bin:$PATH
358
359 make && make install
360     </verb></tscreen>
361     </p>
362   </sect1>
363   <sect1>
364     <heading>Glib/GTK+</heading>
365     <p>
366     <tscreen><verb>
367 tar -xvzf glib-1.2.10.tar.gz
368 cd glib-1.2.10
369 CONFIG_SITE=../ipaq-config.site ./configure \
370       --prefix=/usr/local/arm/2.95.3/arm-linux/usr
371 make
372 make install
373 cd ..
374 tar -xvzf gtk+-1.2.10.tar.gz
375 cd gtk+-1.2.10
376 CONFIG_SITE=../ipaq-config.site ./configure \
377       --prefix=/usr/local/arm/2.95.3/arm-linux/usr --with-glib=../glib-1.2.10
378 make 
379 make install
380     </verb></tscreen>
381     </p>
382   </sect1>
383   <sect1>
384     <heading>ffmpeg</heading>
385     <p>
386     <tscreen><verb>
387 tar -xvzf ffmpeg.tar.gz
388 cd ffmpeg
389 ./configure --cpu=armv4l --cc=arm-linux-gcc --disable-mmx \
390         --prefix=/usr/local/arm/2.95.3/arm-linux/usr --enable-shared
391 cd libavcodec
392 make
393     </verb></tscreen>
394
395     Vlc does not require that you install ffmpeg.
396     </p>
397   </sect1>
398   <sect1>
399     <heading>mad</heading>
400     <p>
401     <tscreen><verb>
402 tar -xvzf mad-0.14.2b.tar.gz
403 cd mad-0.14.2b
404 ./configure --enable-release --target=arm-linux --host=arm-linux \
405       --disable-esd \
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
411 make
412     </verb></tscreen>
413     </p>
414   </sect1>
415   <sect1>
416     <heading>gpe</heading>
417   </sect1>
418   <sect1>
419     <heading>tremor</heading>
420     <p>
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.
423     </p>
424     <p>
425     Log into CVS using the password : <tt>anoncvs</tt>.
426     <tscreen><verb>
427 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot login
428 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co Tremor
429 cd Tremor
430 CONFIG_SITE=../ipaq-config.site ./configure \
431               --prefix=/usr/local/arm/2.95.3/arm-linux/usr
432 make
433 </verb></tscreen>
434     </p>
435   </sect1>
436   <sect1>
437     <heading>ogg</heading>
438     <p>
439     For ogg, it is the same as Tremor.
440     <tscreen><verb>
441 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot login
442 cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co ogg
443 cd ogg
444 CONFIG_SITE=../ipaq-config.site ./configure \
445              --prefix=/usr/local/arm/2.95.3/arm-linux/usr
446 make
447     </verb></tscreen>
448     </p>
449   </sect1>
450   <sect1>
451     <heading>flac</heading>
452     <p>
453     <tscreen><verb>
454 tar -xvzf flac-1.1.0.tar.gz
455 cd flac-1.1.0
456 ./configure --enable-release --host=arm-linux --target=arm-linux \
457             --prefix=/usr/local/arm/2.95.3/arm-linux/usr
458     </verb></tscreen>
459     It will probably fail (due to the xmms plugin), but it is not a problem, 
460     we will continue installation by hand.
461     <tscreen><verb>
462 cp -Rf include/FLAC /usr/local/arm/2.95.3/arm-linux/include
463 cd src/libFLAC
464 make install
465     </verb></tscreen>
466     </p>
467   </sect1>
468   <sect1>
469     <heading>libdvbpsi</heading>
470     <p>
471     <tscreen><verb>
472 tar -xvzf libdvbpsi-0.1.2.tar.gz
473 cd libdvbpsi-0.1.2
474 ./bootstrap
475 ./configure --target=arm-linux --host=arm-linux
476 make
477     </verb></tscreen>
478     </p>
479   </sect1>
480   <sect1>
481     <heading>a52</heading>
482     <p>
483     <tscreen><verb>
484 tar -xvzf a52dec-0.7.4.tar.gz
485 cd a52dec-0.7.4
486 ./configure --enable-release --host=arm-linux --target=arm-linux \
487             --prefix=/usr/local/arm/2.95.3/arm-linux/usr
488 make && make install
489     </verb></tscreen>
490     </p>
491   </sect1>
492 </sect>
493
494 <sect>
495   <heading>Cross compiling vlc itself</heading>
496   <p>
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.
500   </p>
501   <p>
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.
504   </p>
505   <p>
506     Enjoy !
507   </p>
508 </sect>
509
510
511 </article></linuxdoc>