Fix a bunch of platform name and other typos.
[libav.git] / doc / platform.texi
CommitLineData
1de6e14e
LB
1\input texinfo @c -*- texinfo -*-
2
3@settitle Platform Specific information
4@titlepage
5@center @titlefont{Platform Specific information}
6@end titlepage
7
8@top
9
10@contents
11
12@chapter Unix-like
13
14Some parts of Libav cannot be built with version 2.15 of the GNU
15assembler which is still provided by a few AMD64 distributions. To
16make sure your compiler really uses the required version of gas
17after a binutils upgrade, run:
18
19@example
20$(gcc -print-prog-name=as) --version
21@end example
22
23If not, then you should install a different compiler that has no
24hard-coded path to gas. In the worst case pass @code{--disable-asm}
25to configure.
26
27@section BSD
28
29BSD make will not build Libav, you need to install and use GNU Make
30(@file{gmake}).
31
32@section (Open)Solaris
33
34GNU Make is required to build Libav, so you have to invoke (@file{gmake}),
35standard Solaris Make will not work. When building with a non-c99 front-end
36(gcc, generic suncc) add either @code{--extra-libs=/usr/lib/values-xpg6.o}
37or @code{--extra-libs=/usr/lib/64/values-xpg6.o} to the configure options
38since the libc is not c99-compliant by default. The probes performed by
39configure may raise an exception leading to the death of configure itself
40due to a bug in the system shell. Simply invoke a different shell such as
41bash directly to work around this:
42
43@example
44bash ./configure
45@end example
46
47@anchor{Darwin}
5ea20630 48@section Darwin (OS X, iPhone)
1de6e14e
LB
49
50The toolchain provided with Xcode is sufficient to build the basic
51unacelerated code.
52
5ea20630 53OS X on PowerPC or ARM (iPhone) requires a preprocessor from
1de6e14e
LB
54@url{http://github.com/yuvi/gas-preprocessor} to build the optimized
55assembler functions. Just download the Perl script and put it somewhere
56in your PATH, Libav's configure will pick it up automatically.
57
5ea20630 58OS X on AMD64 and x86 requires @command{yasm} to build most of the
1de6e14e
LB
59optimized assembler functions @url{http://mxcl.github.com/homebrew/, Homebrew},
60@url{http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml, Gentoo Prefix}
61or @url{http://www.macports.org, MacPorts} can easily provide it.
62
63
64@chapter DOS
65
66Using a cross-compiler is preferred for various reasons.
67@url{http://www.delorie.com/howto/djgpp/linux-x-djgpp.html}
68
69
70@chapter OS/2
71
72For information about compiling Libav on OS/2 see
73@url{http://www.edm2.com/index.php/FFmpeg}.
74
75
76@chapter Windows
77
78@section Native Windows compilation
79
80Libav can be built to run natively on Windows using the MinGW tools. Install
81the latest versions of MSYS and MinGW from @url{http://www.mingw.org/}.
82You can find detailed installation
83instructions in the download section and the FAQ.
84
85Libav does not build out-of-the-box with the packages the automated MinGW
86installer provides. It also requires coreutils to be installed and many other
87packages updated to the latest version. The minimum version for some packages
88are listed below:
89
90@itemize
91@item bash 3.1
92@item msys-make 3.81-2 (note: not mingw32-make)
93@item w32api 3.13
94@item mingw-runtime 3.15
95@end itemize
96
97Libav automatically passes @code{-fno-common} to the compiler to work around
98a GCC bug (see @url{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216}).
99
100Notes:
101
102@itemize
103
104@item Building natively using MSYS can be sped up by disabling implicit rules
105in the Makefile by calling @code{make -r} instead of plain @code{make}. This
106speed up is close to non-existent for normal one-off builds and is only
107noticeable when running make for a second time (for example in
108@code{make install}).
109
110@item In order to compile AVplay, you must have the MinGW development library
111of @uref{http://www.libsdl.org/, SDL}.
112Edit the @file{bin/sdl-config} script so that it points to the correct prefix
113where SDL was installed. Verify that @file{sdl-config} can be launched from
114the MSYS command line.
115
116@item By using @code{./configure --enable-shared} when configuring Libav,
117you can build libavutil, libavcodec and libavformat as DLLs.
118
119@end itemize
120
121@section Microsoft Visual C++ compatibility
122
123As stated in the FAQ, Libav will not compile under MSVC++. However, if you
124want to use the libav* libraries in your own applications, you can still
125compile those applications using MSVC++. But the libav* libraries you link
126to @emph{must} be built with MinGW. However, you will not be able to debug
127inside the libav* libraries, since MSVC++ does not recognize the debug
128symbols generated by GCC.
129We strongly recommend you to move over from MSVC++ to MinGW tools.
130
131This description of how to use the Libav libraries with MSVC++ is based on
132Microsoft Visual C++ 2005 Express Edition. If you have a different version,
133you might have to modify the procedures slightly.
134
135@subsection Using static libraries
136
137Assuming you have just built and installed Libav in @file{/usr/local}.
138
139@enumerate
140
141@item Create a new console application ("File / New / Project") and then
142select "Win32 Console Application". On the appropriate page of the
143Application Wizard, uncheck the "Precompiled headers" option.
144
145@item Write the source code for your application, or, for testing, just
146copy the code from an existing sample application into the source file
147that MSVC++ has already created for you. For example, you can copy
148@file{libavformat/output-example.c} from the Libav distribution.
149
150@item Open the "Project / Properties" dialog box. In the "Configuration"
151combo box, select "All Configurations" so that the changes you make will
152affect both debug and release builds. In the tree view on the left hand
153side, select "C/C++ / General", then edit the "Additional Include
154Directories" setting to contain the path where the Libav includes were
155installed (i.e. @file{c:\msys\1.0\local\include}).
156Do not add MinGW's include directory here, or the include files will
157conflict with MSVC's.
158
159@item Still in the "Project / Properties" dialog box, select
160"Linker / General" from the tree view and edit the
161"Additional Library Directories" setting to contain the @file{lib}
162directory where Libav was installed (i.e. @file{c:\msys\1.0\local\lib}),
163the directory where MinGW libs are installed (i.e. @file{c:\mingw\lib}),
164and the directory where MinGW's GCC libs are installed
165(i.e. @file{C:\mingw\lib\gcc\mingw32\4.2.1-sjlj}). Then select
166"Linker / Input" from the tree view, and add the files @file{libavformat.a},
167@file{libavcodec.a}, @file{libavutil.a}, @file{libmingwex.a},
168@file{libgcc.a}, and any other libraries you used (i.e. @file{libz.a})
169to the end of "Additional Dependencies".
170
171@item Now, select "C/C++ / Code Generation" from the tree view. Select
172"Debug" in the "Configuration" combo box. Make sure that "Runtime
173Library" is set to "Multi-threaded Debug DLL". Then, select "Release" in
174the "Configuration" combo box and make sure that "Runtime Library" is
175set to "Multi-threaded DLL".
176
177@item Click "OK" to close the "Project / Properties" dialog box.
178
179@item MSVC++ lacks some C99 header files that are fundamental for Libav.
180Get msinttypes from @url{http://code.google.com/p/msinttypes/downloads/list}
181and install it in MSVC++'s include directory
182(i.e. @file{C:\Program Files\Microsoft Visual Studio 8\VC\include}).
183
184@item MSVC++ also does not understand the @code{inline} keyword used by
185Libav, so you must add this line before @code{#include}ing libav*:
186@example
187#define inline _inline
188@end example
189
190@item Build your application, everything should work.
191
192@end enumerate
193
194@subsection Using shared libraries
195
196This is how to create DLL and LIB files that are compatible with MSVC++:
197
198Within the MSYS shell, build Libav with
199
200@example
201./configure --enable-shared
202make
203make install
204@end example
205
206Your install path (@file{/usr/local/} by default) should now have the
207necessary DLL and LIB files under the @file{bin} directory.
208
209Alternatively, build the libraries with a cross compiler, according to
210the instructions below in @ref{Cross compilation for Windows with Linux}.
211
212To use those files with MSVC++, do the same as you would do with
213the static libraries, as described above. But in Step 4,
214you should only need to add the directory where the LIB files are installed
215(i.e. @file{c:\msys\usr\local\bin}). This is not a typo, the LIB files are
216installed in the @file{bin} directory. And instead of adding the static
217libraries (@file{libxxx.a} files) you should add the MSVC import libraries
218(@file{avcodec.lib}, @file{avformat.lib}, and
219@file{avutil.lib}). Note that you should not use the GCC import
220libraries (@file{libxxx.dll.a} files), as these will give you undefined
221reference errors. There should be no need for @file{libmingwex.a},
222@file{libgcc.a}, and @file{wsock32.lib}, nor any other external library
223statically linked into the DLLs.
224
225Libav headers do not declare global data for Windows DLLs through the usual
226dllexport/dllimport interface. Such data will be exported properly while
227building, but to use them in your MSVC++ code you will have to edit the
228appropriate headers and mark the data as dllimport. For example, in
229libavutil/pixdesc.h you should have:
230@example
231extern __declspec(dllimport) const AVPixFmtDescriptor av_pix_fmt_descriptors[];
232@end example
233
234Note that using import libraries created by dlltool requires
235the linker optimization option to be set to
236"References: Keep Unreferenced Data (@code{/OPT:NOREF})", otherwise
237the resulting binaries will fail during runtime. This isn't
238required when using import libraries generated by lib.exe.
239This issue is reported upstream at
240@url{http://sourceware.org/bugzilla/show_bug.cgi?id=12633}.
241
242To create import libraries that work with the @code{/OPT:REF} option
243(which is enabled by default in Release mode), follow these steps:
244
245@enumerate
246
247@item Open @file{Visual Studio 2005 Command Prompt}.
248
249Alternatively, in a normal command line prompt, call @file{vcvars32.bat}
250which sets up the environment variables for the Visual C++ tools
251(the standard location for this file is
252@file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat}).
253
254@item Enter the @file{bin} directory where the created LIB and DLL files
255are stored.
256
257@item Generate new import libraries with @file{lib.exe}:
258
259@example
260lib /machine:i386 /def:..\lib\avcodec-53.def /out:avcodec.lib
261lib /machine:i386 /def:..\lib\avdevice-53.def /out:avdevice.lib
262lib /machine:i386 /def:..\lib\avfilter-2.def /out:avfilter.lib
263lib /machine:i386 /def:..\lib\avformat-53.def /out:avformat.lib
264lib /machine:i386 /def:..\lib\avutil-51.def /out:avutil.lib
265lib /machine:i386 /def:..\lib\swscale-2.def /out:swscale.lib
266@end example
267
268@end enumerate
269
270@anchor{Cross compilation for Windows with Linux}
271@section Cross compilation for Windows with Linux
272
273You must use the MinGW cross compilation tools available at
274@url{http://www.mingw.org/}.
275
276Then configure Libav with the following options:
277@example
278./configure --target-os=mingw32 --cross-prefix=i386-mingw32msvc-
279@end example
280(you can change the cross-prefix according to the prefix chosen for the
281MinGW tools).
282
283Then you can easily test Libav with @uref{http://www.winehq.com/, Wine}.
284
285@section Compilation under Cygwin
286
287Please use Cygwin 1.7.x as the obsolete 1.5.x Cygwin versions lack
288llrint() in its C library.
289
290Install your Cygwin with all the "Base" packages, plus the
291following "Devel" ones:
292@example
293binutils, gcc4-core, make, git, mingw-runtime, texi2html
294@end example
295
296And the following "Utils" one:
297@example
298diffutils
299@end example
300
301Then run
302
303@example
304./configure
305@end example
306
307to make a static build.
308
309The current @code{gcc4-core} package is buggy and needs this flag to build
310shared libraries:
311
312@example
313./configure --enable-shared --disable-static --extra-cflags=-fno-reorder-functions
314@end example
315
316If you want to build Libav with additional libraries, download Cygwin
317"Devel" packages for Ogg and Vorbis from any Cygwin packages repository:
318@example
319libogg-devel, libvorbis-devel
320@end example
321
322These library packages are only available from
323@uref{http://sourceware.org/cygwinports/, Cygwin Ports}:
324
325@example
326yasm, libSDL-devel, libdirac-devel, libfaac-devel, libgsm-devel,
327libmp3lame-devel, libschroedinger1.0-devel, speex-devel, libtheora-devel,
328libxvidcore-devel
329@end example
330
331The recommendation for libnut and x264 is to build them from source by
332yourself, as they evolve too quickly for Cygwin Ports to be up to date.
333
334Cygwin 1.7.x has IPv6 support. You can add IPv6 to Cygwin 1.5.x by means
335of the @code{libgetaddrinfo-devel} package, available at Cygwin Ports.
336
337@section Crosscompilation for Windows under Cygwin
338
339With Cygwin you can create Windows binaries that do not need the cygwin1.dll.
340
341Just install your Cygwin as explained before, plus these additional
342"Devel" packages:
343@example
344gcc-mingw-core, mingw-runtime, mingw-zlib
345@end example
346
347and add some special flags to your configure invocation.
348
349For a static build run
350@example
351./configure --target-os=mingw32 --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
352@end example
353
354and for a build with shared libraries
355@example
356./configure --target-os=mingw32 --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
357@end example
358
359@bye