You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

396 lines
20KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
  4. <head>
  5. <meta charset="utf-8">
  6. <title>
  7. Platform Specific Information
  8. </title>
  9. <meta name="viewport" content="width=device-width,initial-scale=1.0">
  10. <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
  11. <link rel="stylesheet" type="text/css" href="style.min.css">
  12. </head>
  13. <body>
  14. <div class="container">
  15. <h1>
  16. Platform Specific Information
  17. </h1>
  18. <div align="center">
  19. </div>
  20. <a name="SEC_Top"></a>
  21. <div class="Contents_element" id="SEC_Contents">
  22. <h2 class="contents-heading">Table of Contents</h2>
  23. <div class="contents">
  24. <ul class="no-bullet">
  25. <li><a id="toc-Unix_002dlike" href="#Unix_002dlike">1 Unix-like</a>
  26. <ul class="no-bullet">
  27. <li><a id="toc-Advanced-linking-configuration" href="#Advanced-linking-configuration">1.1 Advanced linking configuration</a></li>
  28. <li><a id="toc-BSD" href="#BSD">1.2 BSD</a></li>
  29. <li><a id="toc-_0028Open_0029Solaris" href="#g_t_0028Open_0029Solaris">1.3 (Open)Solaris</a></li>
  30. <li><a id="toc-Darwin-_0028Mac-OS-X_002c-iPhone_0029" href="#Darwin-_0028Mac-OS-X_002c-iPhone_0029">1.4 Darwin (Mac OS X, iPhone)</a></li>
  31. </ul></li>
  32. <li><a id="toc-DOS" href="#DOS">2 DOS</a></li>
  33. <li><a id="toc-OS_002f2" href="#OS_002f2">3 OS/2</a></li>
  34. <li><a id="toc-Windows" href="#Windows">4 Windows</a>
  35. <ul class="no-bullet">
  36. <li><a id="toc-Native-Windows-compilation-using-MinGW-or-MinGW_002dw64" href="#Native-Windows-compilation-using-MinGW-or-MinGW_002dw64">4.1 Native Windows compilation using MinGW or MinGW-w64</a>
  37. <ul class="no-bullet">
  38. <li><a id="toc-Native-Windows-compilation-using-MSYS2" href="#Native-Windows-compilation-using-MSYS2">4.1.1 Native Windows compilation using MSYS2</a></li>
  39. </ul></li>
  40. <li><a id="toc-Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows" href="#Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows">4.2 Microsoft Visual C++ or Intel C++ Compiler for Windows</a>
  41. <ul class="no-bullet">
  42. <li><a id="toc-Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b" href="#Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b">4.2.1 Linking to FFmpeg with Microsoft Visual C++</a></li>
  43. </ul></li>
  44. <li><a id="toc-Cross-compilation-for-Windows-with-Linux-1" href="#Cross-compilation-for-Windows-with-Linux-1">4.3 Cross compilation for Windows with Linux</a></li>
  45. <li><a id="toc-Compilation-under-Cygwin" href="#Compilation-under-Cygwin">4.4 Compilation under Cygwin</a></li>
  46. <li><a id="toc-Crosscompilation-for-Windows-under-Cygwin" href="#Crosscompilation-for-Windows-under-Cygwin">4.5 Crosscompilation for Windows under Cygwin</a></li>
  47. </ul></li>
  48. </ul>
  49. </div>
  50. </div>
  51. <a name="Unix_002dlike"></a>
  52. <h2 class="chapter">1 Unix-like<span class="pull-right"><a class="anchor hidden-xs" href="#Unix_002dlike" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Unix_002dlike" aria-hidden="true">TOC</a></span></h2>
  53. <p>Some parts of FFmpeg cannot be built with version 2.15 of the GNU
  54. assembler which is still provided by a few AMD64 distributions. To
  55. make sure your compiler really uses the required version of gas
  56. after a binutils upgrade, run:
  57. </p>
  58. <div class="example">
  59. <pre class="example">$(gcc -print-prog-name=as) --version
  60. </pre></div>
  61. <p>If not, then you should install a different compiler that has no
  62. hard-coded path to gas. In the worst case pass <code>--disable-asm</code>
  63. to configure.
  64. </p>
  65. <a name="Advanced-linking-configuration"></a>
  66. <h3 class="section">1.1 Advanced linking configuration<span class="pull-right"><a class="anchor hidden-xs" href="#Advanced-linking-configuration" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Advanced-linking-configuration" aria-hidden="true">TOC</a></span></h3>
  67. <p>If you compiled FFmpeg libraries statically and you want to use them to
  68. build your own shared library, you may need to force PIC support (with
  69. <code>--enable-pic</code> during FFmpeg configure) and add the following option
  70. to your project LDFLAGS:
  71. </p>
  72. <div class="example">
  73. <pre class="example">-Wl,-Bsymbolic
  74. </pre></div>
  75. <p>If your target platform requires position independent binaries, you should
  76. pass the correct linking flag (e.g. <code>-pie</code>) to <code>--extra-ldexeflags</code>.
  77. </p>
  78. <a name="BSD"></a>
  79. <h3 class="section">1.2 BSD<span class="pull-right"><a class="anchor hidden-xs" href="#BSD" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-BSD" aria-hidden="true">TOC</a></span></h3>
  80. <p>BSD make will not build FFmpeg, you need to install and use GNU Make
  81. (<code>gmake</code>).
  82. </p>
  83. <a name="g_t_0028Open_0029Solaris"></a>
  84. <h3 class="section">1.3 (Open)Solaris<span class="pull-right"><a class="anchor hidden-xs" href="#_0028Open_0029Solaris" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-_0028Open_0029Solaris" aria-hidden="true">TOC</a></span></h3>
  85. <p>GNU Make is required to build FFmpeg, so you have to invoke (<code>gmake</code>),
  86. standard Solaris Make will not work. When building with a non-c99 front-end
  87. (gcc, generic suncc) add either <code>--extra-libs=/usr/lib/values-xpg6.o</code>
  88. or <code>--extra-libs=/usr/lib/64/values-xpg6.o</code> to the configure options
  89. since the libc is not c99-compliant by default. The probes performed by
  90. configure may raise an exception leading to the death of configure itself
  91. due to a bug in the system shell. Simply invoke a different shell such as
  92. bash directly to work around this:
  93. </p>
  94. <div class="example">
  95. <pre class="example">bash ./configure
  96. </pre></div>
  97. <span id="Darwin"></span><a name="Darwin-_0028Mac-OS-X_002c-iPhone_0029"></a>
  98. <h3 class="section">1.4 Darwin (Mac OS X, iPhone)<span class="pull-right"><a class="anchor hidden-xs" href="#Darwin-_0028Mac-OS-X_002c-iPhone_0029" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Darwin-_0028Mac-OS-X_002c-iPhone_0029" aria-hidden="true">TOC</a></span></h3>
  99. <p>The toolchain provided with Xcode is sufficient to build the basic
  100. unaccelerated code.
  101. </p>
  102. <p>Mac OS X on PowerPC or ARM (iPhone) requires a preprocessor from
  103. <a href="https://github.com/FFmpeg/gas-preprocessor">https://github.com/FFmpeg/gas-preprocessor</a> or
  104. <a href="https://github.com/yuvi/gas-preprocessor">https://github.com/yuvi/gas-preprocessor</a>(currently outdated) to build the optimized
  105. assembly functions. Put the Perl script somewhere
  106. in your PATH, FFmpeg&rsquo;s configure will pick it up automatically.
  107. </p>
  108. <p>Mac OS X on amd64 and x86 requires <code>nasm</code> to build most of the
  109. optimized assembly functions. <a href="http://www.finkproject.org/">Fink</a>,
  110. <a href="https://wiki.gentoo.org/wiki/Project:Prefix">Gentoo Prefix</a>,
  111. <a href="https://mxcl.github.com/homebrew/">Homebrew</a>
  112. or <a href="http://www.macports.org">MacPorts</a> can easily provide it.
  113. </p>
  114. <a name="DOS"></a>
  115. <h2 class="chapter">2 DOS<span class="pull-right"><a class="anchor hidden-xs" href="#DOS" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-DOS" aria-hidden="true">TOC</a></span></h2>
  116. <p>Using a cross-compiler is preferred for various reasons.
  117. <a href="http://www.delorie.com/howto/djgpp/linux-x-djgpp.html">http://www.delorie.com/howto/djgpp/linux-x-djgpp.html</a>
  118. </p>
  119. <a name="OS_002f2"></a>
  120. <h2 class="chapter">3 OS/2<span class="pull-right"><a class="anchor hidden-xs" href="#OS_002f2" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-OS_002f2" aria-hidden="true">TOC</a></span></h2>
  121. <p>For information about compiling FFmpeg on OS/2 see
  122. <a href="http://www.edm2.com/index.php/FFmpeg">http://www.edm2.com/index.php/FFmpeg</a>.
  123. </p>
  124. <a name="Windows"></a>
  125. <h2 class="chapter">4 Windows<span class="pull-right"><a class="anchor hidden-xs" href="#Windows" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Windows" aria-hidden="true">TOC</a></span></h2>
  126. <p>To get help and instructions for building FFmpeg under Windows, check out
  127. the FFmpeg Windows Help Forum at <a href="http://ffmpeg.zeranoe.com/forum/">http://ffmpeg.zeranoe.com/forum/</a>.
  128. </p>
  129. <a name="Native-Windows-compilation-using-MinGW-or-MinGW_002dw64"></a>
  130. <h3 class="section">4.1 Native Windows compilation using MinGW or MinGW-w64<span class="pull-right"><a class="anchor hidden-xs" href="#Native-Windows-compilation-using-MinGW-or-MinGW_002dw64" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Native-Windows-compilation-using-MinGW-or-MinGW_002dw64" aria-hidden="true">TOC</a></span></h3>
  131. <p>FFmpeg can be built to run natively on Windows using the MinGW-w64
  132. toolchain. Install the latest versions of MSYS2 and MinGW-w64 from
  133. <a href="http://msys2.github.io/">http://msys2.github.io/</a> and/or <a href="http://mingw-w64.sourceforge.net/">http://mingw-w64.sourceforge.net/</a>.
  134. You can find detailed installation instructions in the download section and
  135. the FAQ.
  136. </p>
  137. <p>Notes:
  138. </p>
  139. <ul>
  140. <li> Building for the MSYS environment is discouraged, MSYS2 provides a full
  141. MinGW-w64 environment through <samp>mingw64_shell.bat</samp> or
  142. <samp>mingw32_shell.bat</samp> that should be used instead of the environment
  143. provided by <samp>msys2_shell.bat</samp>.
  144. </li><li> Building using MSYS2 can be sped up by disabling implicit rules in the
  145. Makefile by calling <code>make -r</code> instead of plain <code>make</code>. This
  146. speed up is close to non-existent for normal one-off builds and is only
  147. noticeable when running make for a second time (for example during
  148. <code>make install</code>).
  149. </li><li> In order to compile FFplay, you must have the MinGW development library
  150. of <a href="http://www.libsdl.org/">SDL</a> and <code>pkg-config</code> installed.
  151. </li><li> By using <code>./configure --enable-shared</code> when configuring FFmpeg,
  152. you can build the FFmpeg libraries (e.g. libavutil, libavcodec,
  153. libavformat) as DLLs.
  154. </li></ul>
  155. <a name="Native-Windows-compilation-using-MSYS2"></a>
  156. <h4 class="subsection">4.1.1 Native Windows compilation using MSYS2<span class="pull-right"><a class="anchor hidden-xs" href="#Native-Windows-compilation-using-MSYS2" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Native-Windows-compilation-using-MSYS2" aria-hidden="true">TOC</a></span></h4>
  157. <p>The MSYS2 MinGW-w64 environment provides ready to use toolchains and dependencies
  158. through <code>pacman</code>.
  159. </p>
  160. <p>Make sure to use <samp>mingw64_shell.bat</samp> or <samp>mingw32_shell.bat</samp> to have
  161. the correct MinGW-w64 environment. The default install provides shortcuts to
  162. them under <code>MinGW-w64 Win64 Shell</code> and <code>MinGW-w64 Win32 Shell</code>.
  163. </p>
  164. <div class="example">
  165. <pre class="example"># normal msys2 packages
  166. pacman -S make pkgconf diffutils
  167. # mingw-w64 packages and toolchains
  168. pacman -S mingw-w64-x86_64-nasm mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL2
  169. </pre></div>
  170. <p>To target 32 bits replace <code>x86_64</code> with <code>i686</code> in the command above.
  171. </p>
  172. <a name="Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows"></a>
  173. <h3 class="section">4.2 Microsoft Visual C++ or Intel C++ Compiler for Windows<span class="pull-right"><a class="anchor hidden-xs" href="#Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows" aria-hidden="true">TOC</a></span></h3>
  174. <p>FFmpeg can be built with MSVC 2013 or later.
  175. </p>
  176. <p>You will need the following prerequisites:
  177. </p>
  178. <ul>
  179. <li> <a href="http://msys2.github.io/">MSYS2</a>
  180. </li><li> <a href="http://www.nasm.us/">NASM</a>
  181. (Also available via MSYS2&rsquo;s package manager.)
  182. </li></ul>
  183. <p>To set up a proper environment in MSYS2, you need to run <code>msys_shell.bat</code> from
  184. the Visual Studio or Intel Compiler command prompt.
  185. </p>
  186. <p>Place <code>yasm.exe</code> somewhere in your <code>PATH</code>.
  187. </p>
  188. <p>Next, make sure any other headers and libs you want to use, such as zlib, are
  189. located in a spot that the compiler can see. Do so by modifying the <code>LIB</code>
  190. and <code>INCLUDE</code> environment variables to include the <strong>Windows-style</strong>
  191. paths to these directories. Alternatively, you can try to use the
  192. <code>--extra-cflags</code>/<code>--extra-ldflags</code> configure options.
  193. </p>
  194. <p>Finally, run:
  195. </p>
  196. <div class="example">
  197. <pre class="example">For MSVC:
  198. ./configure --toolchain=msvc
  199. For ICL:
  200. ./configure --toolchain=icl
  201. make
  202. make install
  203. </pre></div>
  204. <p>If you wish to compile shared libraries, add <code>--enable-shared</code> to your
  205. configure options. Note that due to the way MSVC and ICL handle DLL imports and
  206. exports, you cannot compile static and shared libraries at the same time, and
  207. enabling shared libraries will automatically disable the static ones.
  208. </p>
  209. <p>Notes:
  210. </p>
  211. <ul>
  212. <li> If you wish to build with zlib support, you will have to grab a compatible
  213. zlib binary from somewhere, with an MSVC import lib, or if you wish to link
  214. statically, you can follow the instructions below to build a compatible
  215. <code>zlib.lib</code> with MSVC. Regardless of which method you use, you must still
  216. follow step 3, or compilation will fail.
  217. <ol>
  218. <li> Grab the <a href="http://zlib.net/">zlib sources</a>.
  219. </li><li> Edit <code>win32/Makefile.msc</code> so that it uses -MT instead of -MD, since
  220. this is how FFmpeg is built as well.
  221. </li><li> Edit <code>zconf.h</code> and remove its inclusion of <code>unistd.h</code>. This gets
  222. erroneously included when building FFmpeg.
  223. </li><li> Run <code>nmake -f win32/Makefile.msc</code>.
  224. </li><li> Move <code>zlib.lib</code>, <code>zconf.h</code>, and <code>zlib.h</code> to somewhere MSVC
  225. can see.
  226. </li></ol>
  227. </li><li> FFmpeg has been tested with the following on i686 and x86_64:
  228. <ul>
  229. <li> Visual Studio 2013 Pro and Express
  230. </li><li> Intel Composer XE 2013
  231. </li><li> Intel Composer XE 2013 SP1
  232. </li></ul>
  233. <p>Anything else is not officially supported.
  234. </p>
  235. </li></ul>
  236. <a name="Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b"></a>
  237. <h4 class="subsection">4.2.1 Linking to FFmpeg with Microsoft Visual C++<span class="pull-right"><a class="anchor hidden-xs" href="#Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b" aria-hidden="true">TOC</a></span></h4>
  238. <p>If you plan to link with MSVC-built static libraries, you will need
  239. to make sure you have <code>Runtime Library</code> set to
  240. <code>Multi-threaded (/MT)</code> in your project&rsquo;s settings.
  241. </p>
  242. <p>You will need to define <code>inline</code> to something MSVC understands:
  243. </p><div class="example">
  244. <pre class="example">#define inline __inline
  245. </pre></div>
  246. <p>Also note, that as stated in <strong>Microsoft Visual C++</strong>, you will need
  247. an MSVC-compatible <a href="http://code.google.com/p/msinttypes/">inttypes.h</a>.
  248. </p>
  249. <p>If you plan on using import libraries created by dlltool, you must
  250. set <code>References</code> to <code>No (/OPT:NOREF)</code> under the linker optimization
  251. settings, otherwise the resulting binaries will fail during runtime.
  252. This is not required when using import libraries generated by <code>lib.exe</code>.
  253. This issue is reported upstream at
  254. <a href="http://sourceware.org/bugzilla/show_bug.cgi?id=12633">http://sourceware.org/bugzilla/show_bug.cgi?id=12633</a>.
  255. </p>
  256. <p>To create import libraries that work with the <code>/OPT:REF</code> option
  257. (which is enabled by default in Release mode), follow these steps:
  258. </p>
  259. <ol>
  260. <li> Open the <em>Visual Studio Command Prompt</em>.
  261. <p>Alternatively, in a normal command line prompt, call <samp>vcvars32.bat</samp>
  262. which sets up the environment variables for the Visual C++ tools
  263. (the standard location for this file is something like
  264. <samp>C:\Program Files (x86_\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat</samp>).
  265. </p>
  266. </li><li> Enter the <samp>bin</samp> directory where the created LIB and DLL files
  267. are stored.
  268. </li><li> Generate new import libraries with <code>lib.exe</code>:
  269. <div class="example">
  270. <pre class="example">lib /machine:i386 /def:..\lib\foo-version.def /out:foo.lib
  271. </pre></div>
  272. <p>Replace <code>foo-version</code> and <code>foo</code> with the respective library names.
  273. </p>
  274. </li></ol>
  275. <span id="Cross-compilation-for-Windows-with-Linux"></span><a name="Cross-compilation-for-Windows-with-Linux-1"></a>
  276. <h3 class="section">4.3 Cross compilation for Windows with Linux<span class="pull-right"><a class="anchor hidden-xs" href="#Cross-compilation-for-Windows-with-Linux-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Cross-compilation-for-Windows-with-Linux-1" aria-hidden="true">TOC</a></span></h3>
  277. <p>You must use the MinGW cross compilation tools available at
  278. <a href="http://www.mingw.org/">http://www.mingw.org/</a>.
  279. </p>
  280. <p>Then configure FFmpeg with the following options:
  281. </p><div class="example">
  282. <pre class="example">./configure --target-os=mingw32 --cross-prefix=i386-mingw32msvc-
  283. </pre></div>
  284. <p>(you can change the cross-prefix according to the prefix chosen for the
  285. MinGW tools).
  286. </p>
  287. <p>Then you can easily test FFmpeg with <a href="http://www.winehq.com/">Wine</a>.
  288. </p>
  289. <a name="Compilation-under-Cygwin"></a>
  290. <h3 class="section">4.4 Compilation under Cygwin<span class="pull-right"><a class="anchor hidden-xs" href="#Compilation-under-Cygwin" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Compilation-under-Cygwin" aria-hidden="true">TOC</a></span></h3>
  291. <p>Please use Cygwin 1.7.x as the obsolete 1.5.x Cygwin versions lack
  292. llrint() in its C library.
  293. </p>
  294. <p>Install your Cygwin with all the &quot;Base&quot; packages, plus the
  295. following &quot;Devel&quot; ones:
  296. </p><div class="example">
  297. <pre class="example">binutils, gcc4-core, make, git, mingw-runtime, texinfo
  298. </pre></div>
  299. <p>In order to run FATE you will also need the following &quot;Utils&quot; packages:
  300. </p><div class="example">
  301. <pre class="example">diffutils
  302. </pre></div>
  303. <p>If you want to build FFmpeg with additional libraries, download Cygwin
  304. &quot;Devel&quot; packages for Ogg and Vorbis from any Cygwin packages repository:
  305. </p><div class="example">
  306. <pre class="example">libogg-devel, libvorbis-devel
  307. </pre></div>
  308. <p>These library packages are only available from
  309. <a href="http://sourceware.org/cygwinports/">Cygwin Ports</a>:
  310. </p>
  311. <div class="example">
  312. <pre class="example">yasm, libSDL-devel, libgsm-devel, libmp3lame-devel,
  313. speex-devel, libtheora-devel, libxvidcore-devel
  314. </pre></div>
  315. <p>The recommendation for x264 is to build it from source, as it evolves too
  316. quickly for Cygwin Ports to be up to date.
  317. </p>
  318. <a name="Crosscompilation-for-Windows-under-Cygwin"></a>
  319. <h3 class="section">4.5 Crosscompilation for Windows under Cygwin<span class="pull-right"><a class="anchor hidden-xs" href="#Crosscompilation-for-Windows-under-Cygwin" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Crosscompilation-for-Windows-under-Cygwin" aria-hidden="true">TOC</a></span></h3>
  320. <p>With Cygwin you can create Windows binaries that do not need the cygwin1.dll.
  321. </p>
  322. <p>Just install your Cygwin as explained before, plus these additional
  323. &quot;Devel&quot; packages:
  324. </p><div class="example">
  325. <pre class="example">gcc-mingw-core, mingw-runtime, mingw-zlib
  326. </pre></div>
  327. <p>and add some special flags to your configure invocation.
  328. </p>
  329. <p>For a static build run
  330. </p><div class="example">
  331. <pre class="example">./configure --target-os=mingw32 --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
  332. </pre></div>
  333. <p>and for a build with shared libraries
  334. </p><div class="example">
  335. <pre class="example">./configure --target-os=mingw32 --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
  336. </pre></div>
  337. <p style="font-size: small;">
  338. This document was generated using <a href="https://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
  339. </p>
  340. </div>
  341. </body>
  342. </html>