platform.texi 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. \input texinfo @c -*- texinfo -*-
  2. @settitle Platform Specific Information
  3. @titlepage
  4. @center @titlefont{Platform Specific Information}
  5. @end titlepage
  6. @top
  7. @contents
  8. @chapter Unix-like
  9. Some parts of FFmpeg cannot be built with version 2.15 of the GNU
  10. assembler which is still provided by a few AMD64 distributions. To
  11. make sure your compiler really uses the required version of gas
  12. after a binutils upgrade, run:
  13. @example
  14. $(gcc -print-prog-name=as) --version
  15. @end example
  16. If not, then you should install a different compiler that has no
  17. hard-coded path to gas. In the worst case pass @code{--disable-asm}
  18. to configure.
  19. @section Advanced linking configuration
  20. If you compiled FFmpeg libraries statically and you want to use them to
  21. build your own shared library, you may need to force PIC support (with
  22. @code{--enable-pic} during FFmpeg configure) and add the following option
  23. to your project LDFLAGS:
  24. @example
  25. -Wl,-Bsymbolic
  26. @end example
  27. @section BSD
  28. BSD make will not build FFmpeg, you need to install and use GNU Make
  29. (@command{gmake}).
  30. @section (Open)Solaris
  31. GNU Make is required to build FFmpeg, so you have to invoke (@command{gmake}),
  32. standard Solaris Make will not work. When building with a non-c99 front-end
  33. (gcc, generic suncc) add either @code{--extra-libs=/usr/lib/values-xpg6.o}
  34. or @code{--extra-libs=/usr/lib/64/values-xpg6.o} to the configure options
  35. since the libc is not c99-compliant by default. The probes performed by
  36. configure may raise an exception leading to the death of configure itself
  37. due to a bug in the system shell. Simply invoke a different shell such as
  38. bash directly to work around this:
  39. @example
  40. bash ./configure
  41. @end example
  42. @anchor{Darwin}
  43. @section Darwin (Mac OS X, iPhone)
  44. The toolchain provided with Xcode is sufficient to build the basic
  45. unacelerated code.
  46. Mac OS X on PowerPC or ARM (iPhone) requires a preprocessor from
  47. @url{https://github.com/FFmpeg/gas-preprocessor} or
  48. @url{https://github.com/yuvi/gas-preprocessor}(currently outdated) to build the optimized
  49. assembly functions. Put the Perl script somewhere
  50. in your PATH, FFmpeg's configure will pick it up automatically.
  51. Mac OS X on amd64 and x86 requires @command{yasm} to build most of the
  52. optimized assembly functions. @uref{http://www.finkproject.org/, Fink},
  53. @uref{http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml, Gentoo Prefix},
  54. @uref{https://mxcl.github.com/homebrew/, Homebrew}
  55. or @uref{http://www.macports.org, MacPorts} can easily provide it.
  56. @chapter DOS
  57. Using a cross-compiler is preferred for various reasons.
  58. @url{http://www.delorie.com/howto/djgpp/linux-x-djgpp.html}
  59. @chapter OS/2
  60. For information about compiling FFmpeg on OS/2 see
  61. @url{http://www.edm2.com/index.php/FFmpeg}.
  62. @chapter Windows
  63. To get help and instructions for building FFmpeg under Windows, check out
  64. the FFmpeg Windows Help Forum at @url{http://ffmpeg.zeranoe.com/forum/}.
  65. @section Native Windows compilation using MinGW or MinGW-w64
  66. FFmpeg can be built to run natively on Windows using the MinGW or MinGW-w64
  67. toolchains. Install the latest versions of MSYS and MinGW or MinGW-w64 from
  68. @url{http://www.mingw.org/} or @url{http://mingw-w64.sourceforge.net/}.
  69. You can find detailed installation instructions in the download section and
  70. the FAQ.
  71. Notes:
  72. @itemize
  73. @item Building natively using MSYS can be sped up by disabling implicit rules
  74. in the Makefile by calling @code{make -r} instead of plain @code{make}. This
  75. speed up is close to non-existent for normal one-off builds and is only
  76. noticeable when running make for a second time (for example during
  77. @code{make install}).
  78. @item In order to compile FFplay, you must have the MinGW development library
  79. of @uref{http://www.libsdl.org/, SDL} and @code{pkg-config} installed.
  80. @item By using @code{./configure --enable-shared} when configuring FFmpeg,
  81. you can build the FFmpeg libraries (e.g. libavutil, libavcodec,
  82. libavformat) as DLLs.
  83. @end itemize
  84. @section Microsoft Visual C++ or Intel C++ Compiler for Windows
  85. FFmpeg can be built with MSVC 2012 or earlier using a C99-to-C89 conversion utility
  86. and wrapper, or with MSVC 2013 and ICL natively.
  87. You will need the following prerequisites:
  88. @itemize
  89. @item @uref{https://github.com/libav/c99-to-c89/, C99-to-C89 Converter & Wrapper}
  90. (if using MSVC 2012 or earlier)
  91. @item @uref{http://code.google.com/p/msinttypes/, msinttypes}
  92. (if using MSVC 2012 or earlier)
  93. @item @uref{http://www.mingw.org/, MSYS}
  94. @item @uref{http://yasm.tortall.net/, YASM}
  95. @item @uref{http://gnuwin32.sourceforge.net/packages/bc.htm, bc for Windows} if
  96. you want to run @uref{fate.html, FATE}.
  97. @end itemize
  98. To set up a proper environment in MSYS, you need to run @code{msys.bat} from
  99. the Visual Studio or Intel Compiler command prompt.
  100. Place @code{yasm.exe} somewhere in your @code{PATH}. If using MSVC 2012 or
  101. earlier, place @code{c99wrap.exe} and @code{c99conv.exe} somewhere in your
  102. @code{PATH} as well.
  103. Next, make sure any other headers and libs you want to use, such as zlib, are
  104. located in a spot that the compiler can see. Do so by modifying the @code{LIB}
  105. and @code{INCLUDE} environment variables to include the @strong{Windows-style}
  106. paths to these directories. Alternatively, you can try and use the
  107. @code{--extra-cflags}/@code{--extra-ldflags} configure options. If using MSVC
  108. 2012 or earlier, place @code{inttypes.h} somewhere the compiler can see too.
  109. Finally, run:
  110. @example
  111. For MSVC:
  112. ./configure --toolchain=msvc
  113. For ICL:
  114. ./configure --toolchain=icl
  115. make
  116. make install
  117. @end example
  118. If you wish to compile shared libraries, add @code{--enable-shared} to your
  119. configure options. Note that due to the way MSVC and ICL handle DLL imports and
  120. exports, you cannot compile static and shared libraries at the same time, and
  121. enabling shared libraries will automatically disable the static ones.
  122. Notes:
  123. @itemize
  124. @item It is possible that coreutils' @code{link.exe} conflicts with MSVC's linker.
  125. You can find out by running @code{which link} to see which @code{link.exe} you
  126. are using. If it is located at @code{/bin/link.exe}, then you have the wrong one
  127. in your @code{PATH}. Either move or remove that copy, or make sure MSVC's
  128. @code{link.exe} takes precedence in your @code{PATH} over coreutils'.
  129. @item If you wish to build with zlib support, you will have to grab a compatible
  130. zlib binary from somewhere, with an MSVC import lib, or if you wish to link
  131. statically, you can follow the instructions below to build a compatible
  132. @code{zlib.lib} with MSVC. Regardless of which method you use, you must still
  133. follow step 3, or compilation will fail.
  134. @enumerate
  135. @item Grab the @uref{http://zlib.net/, zlib sources}.
  136. @item Edit @code{win32/Makefile.msc} so that it uses -MT instead of -MD, since
  137. this is how FFmpeg is built as well.
  138. @item Edit @code{zconf.h} and remove its inclusion of @code{unistd.h}. This gets
  139. erroneously included when building FFmpeg.
  140. @item Run @code{nmake -f win32/Makefile.msc}.
  141. @item Move @code{zlib.lib}, @code{zconf.h}, and @code{zlib.h} to somewhere MSVC
  142. can see.
  143. @end enumerate
  144. @item FFmpeg has been tested with the following on i686 and x86_64:
  145. @itemize
  146. @item Visual Studio 2010 Pro and Express
  147. @item Visual Studio 2012 Pro and Express
  148. @item Visual Studio 2013 Pro and Express
  149. @item Intel Composer XE 2013
  150. @item Intel Composer XE 2013 SP1
  151. @end itemize
  152. Anything else is not officially supported.
  153. @end itemize
  154. @subsection Linking to FFmpeg with Microsoft Visual C++
  155. If you plan to link with MSVC-built static libraries, you will need
  156. to make sure you have @code{Runtime Library} set to
  157. @code{Multi-threaded (/MT)} in your project's settings.
  158. You will need to define @code{inline} to something MSVC understands:
  159. @example
  160. #define inline __inline
  161. @end example
  162. Also note, that as stated in @strong{Microsoft Visual C++}, you will need
  163. an MSVC-compatible @uref{http://code.google.com/p/msinttypes/, inttypes.h}.
  164. If you plan on using import libraries created by dlltool, you must
  165. set @code{References} to @code{No (/OPT:NOREF)} under the linker optimization
  166. settings, otherwise the resulting binaries will fail during runtime.
  167. This is not required when using import libraries generated by @code{lib.exe}.
  168. This issue is reported upstream at
  169. @url{http://sourceware.org/bugzilla/show_bug.cgi?id=12633}.
  170. To create import libraries that work with the @code{/OPT:REF} option
  171. (which is enabled by default in Release mode), follow these steps:
  172. @enumerate
  173. @item Open the @emph{Visual Studio Command Prompt}.
  174. Alternatively, in a normal command line prompt, call @file{vcvars32.bat}
  175. which sets up the environment variables for the Visual C++ tools
  176. (the standard location for this file is something like
  177. @file{C:\Program Files (x86_\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat}).
  178. @item Enter the @file{bin} directory where the created LIB and DLL files
  179. are stored.
  180. @item Generate new import libraries with @command{lib.exe}:
  181. @example
  182. lib /machine:i386 /def:..\lib\foo-version.def /out:foo.lib
  183. @end example
  184. Replace @code{foo-version} and @code{foo} with the respective library names.
  185. @end enumerate
  186. @anchor{Cross compilation for Windows with Linux}
  187. @section Cross compilation for Windows with Linux
  188. You must use the MinGW cross compilation tools available at
  189. @url{http://www.mingw.org/}.
  190. Then configure FFmpeg with the following options:
  191. @example
  192. ./configure --target-os=mingw32 --cross-prefix=i386-mingw32msvc-
  193. @end example
  194. (you can change the cross-prefix according to the prefix chosen for the
  195. MinGW tools).
  196. Then you can easily test FFmpeg with @uref{http://www.winehq.com/, Wine}.
  197. @section Compilation under Cygwin
  198. Please use Cygwin 1.7.x as the obsolete 1.5.x Cygwin versions lack
  199. llrint() in its C library.
  200. Install your Cygwin with all the "Base" packages, plus the
  201. following "Devel" ones:
  202. @example
  203. binutils, gcc4-core, make, git, mingw-runtime, texi2html
  204. @end example
  205. In order to run FATE you will also need the following "Utils" packages:
  206. @example
  207. bc, diffutils
  208. @end example
  209. If you want to build FFmpeg with additional libraries, download Cygwin
  210. "Devel" packages for Ogg and Vorbis from any Cygwin packages repository:
  211. @example
  212. libogg-devel, libvorbis-devel
  213. @end example
  214. These library packages are only available from
  215. @uref{http://sourceware.org/cygwinports/, Cygwin Ports}:
  216. @example
  217. yasm, libSDL-devel, libfaac-devel, libaacplus-devel, libgsm-devel, libmp3lame-devel,
  218. libschroedinger1.0-devel, speex-devel, libtheora-devel, libxvidcore-devel
  219. @end example
  220. The recommendation for x264 is to build it from source, as it evolves too
  221. quickly for Cygwin Ports to be up to date.
  222. @section Crosscompilation for Windows under Cygwin
  223. With Cygwin you can create Windows binaries that do not need the cygwin1.dll.
  224. Just install your Cygwin as explained before, plus these additional
  225. "Devel" packages:
  226. @example
  227. gcc-mingw-core, mingw-runtime, mingw-zlib
  228. @end example
  229. and add some special flags to your configure invocation.
  230. For a static build run
  231. @example
  232. ./configure --target-os=mingw32 --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
  233. @end example
  234. and for a build with shared libraries
  235. @example
  236. ./configure --target-os=mingw32 --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
  237. @end example
  238. @chapter Plan 9
  239. The native @uref{http://plan9.bell-labs.com/plan9/, Plan 9} compiler
  240. does not implement all the C99 features needed by FFmpeg so the gcc
  241. port must be used. Furthermore, a few items missing from the C
  242. library and shell environment need to be fixed.
  243. @itemize
  244. @item GNU awk, grep, make, and sed
  245. Working packages of these tools can be found at
  246. @uref{http://code.google.com/p/ports2plan9/downloads/list, ports2plan9}.
  247. They can be installed with @uref{http://9front.org/, 9front's} @code{pkg}
  248. utility by setting @code{pkgpath} to
  249. @code{http://ports2plan9.googlecode.com/files/}.
  250. @item Missing/broken @code{head} and @code{printf} commands
  251. Replacements adequate for building FFmpeg can be found in the
  252. @code{compat/plan9} directory. Place these somewhere they will be
  253. found by the shell. These are not full implementations of the
  254. commands and are @emph{not} suitable for general use.
  255. @item Missing C99 @code{stdint.h} and @code{inttypes.h}
  256. Replacement headers are available from
  257. @url{http://code.google.com/p/plan9front/issues/detail?id=152}.
  258. @item Missing or non-standard library functions
  259. Some functions in the C library are missing or incomplete. The
  260. @code{@uref{http://ports2plan9.googlecode.com/files/gcc-apelibs-1207.tbz,
  261. gcc-apelibs-1207}} package from
  262. @uref{http://code.google.com/p/ports2plan9/downloads/list, ports2plan9}
  263. includes an updated C library, but installing the full package gives
  264. unusable executables. Instead, keep the files from @code{gccbin.tgz}
  265. under @code{/386/lib/gnu}. From the @code{libc.a} archive in the
  266. @code{gcc-apelibs-1207} package, extract the following object files and
  267. turn them into a library:
  268. @itemize
  269. @item @code{strerror.o}
  270. @item @code{strtoll.o}
  271. @item @code{snprintf.o}
  272. @item @code{vsnprintf.o}
  273. @item @code{vfprintf.o}
  274. @item @code{_IO_getc.o}
  275. @item @code{_IO_putc.o}
  276. @end itemize
  277. Use the @code{--extra-libs} option of @code{configure} to inform the
  278. build system of this library.
  279. @item FPU exceptions enabled by default
  280. Unlike most other systems, Plan 9 enables FPU exceptions by default.
  281. These must be disabled before calling any FFmpeg functions. While the
  282. included tools will do this automatically, other users of the
  283. libraries must do it themselves.
  284. @end itemize
  285. @bye