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.

388 lines
14KB

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