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