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