From f45b54437a5f3ac28dc96f3b2551b4c602ec10e5 Mon Sep 17 00:00:00 2001 From: Derek Buitenhuis Date: Thu, 27 Sep 2012 18:39:02 +0000 Subject: [PATCH] doc/platform: Replace Visual Studio section with build instructions Signed-off-by: Derek Buitenhuis --- doc/platform.texi | 81 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 13 deletions(-) diff --git a/doc/platform.texi b/doc/platform.texi index ac4b871545..a16bb467ca 100644 --- a/doc/platform.texi +++ b/doc/platform.texi @@ -75,7 +75,7 @@ For information about compiling Libav on OS/2 see @chapter Windows -@section Native Windows compilation +@section Native Windows compilation using MinGW or MinGW-w64 Libav can be built to run natively on Windows using the MinGW or MinGW-w64 toolchains. Install the latest versions of MSYS and MinGW or MinGW-w64 from @@ -101,21 +101,76 @@ you can build all libraries as DLLs. @end itemize -@section Microsoft Visual C++ compatibility +@section Microsoft Visual C++ -As stated in the FAQ, Libav will not compile under MSVC++. However, if you -want to use the libav* libraries in your own applications, you can still -compile those applications using MSVC++. But the libav* libraries you link -to @emph{must} be built with MinGW. However, you will not be able to debug -inside the libav* libraries, since MSVC++ does not recognize the debug -symbols generated by GCC. -We strongly recommend you to move over from MSVC++ to MinGW tools. +Libav can be built with MSVC using a C99-to-C89 conversion utility and +wrapper. At this time, only static builds are supported. -This description of how to use the Libav libraries with MSVC++ is based on -Microsoft Visual C++ 2005 Express Edition. If you have a different version, -you might have to modify the procedures slightly. +You will need the following prerequisites: -@subsection Using shared libraries +@itemize +@item @uref{https://github.com/rbultje/c99-to-c89/, C99-to-C89 Converter & Wrapper} +@item @uref{http://code.google.com/p/msinttypes/, msinttypes} +@item @uref{http://www.mingw.org/, MSYS} +@item @uref{http://yasm.tortall.net/, YASM} +@item @uref{http://gnuwin32.sourceforge.net/packages/bc.htm, bc for Windows} if +you want to run @uref{fate.html, FATE}. +@end itemize + +To set up a proper MSVC environment in MSYS, you simply need to run +@code{msys.bat} from the Visual Studio command prompt. + +Caveat: Run @code{which link} to see which link you are using. If it is located +at @code{/bin/link.exe}, then you have the wrong link in your @code{PATH}. +Either move/remove that copy, or make sure MSVC's link.exe is higher up in your +@code{PATH} than coreutils'. + +Place @code{c99wrap.exe}, @code{c99conv.exe}, and @code{yasm.exe} somewhere +in your @code{PATH}. + +Next, make sure @code{inttypes.h} and any other headers and libs you want to use +are located in a spot that MSVC can see. Do so by modifying the @code{LIB} and +@code{INCLUDE} environment variables to include the @strong{Windows} paths to +these directories. Alternatively, you can try and use the +@code{--extra-cflags}/@code{--extra-ldflags} configure options. + +Finally, run: + +@example +./configure --toolchain=msvc +make +make install +@end example + +Notes: + +@itemize + +@item If you wish to build with zlib support, you will have to grab a compatible +zlib binary from somewhere, with an MSVC import lib, or if you wish to link +statically, you can follow the instructions below to build a compatible +@code{zlib.lib} with MSVC. Regardless of which method you use, you must still +follow step 3, or compilation will fail. +@enumerate +@item Grab the @uref{http://zlib.net/, zlib sources}. +@item Edit @code{win32/Makefile.msc} so that it uses -MT instead of -MD, since +this is how Libav is built as well. +@item Edit @code{zconf.h} and remove its inclusion of @code{unistd.h}. This gets +erroneously included when building Libav. +@item Run @code{nmake -f win32/Makefile.msc}. +@item Move @code{zlib.lib}, @code{zconf.h}, and @code{zlib.h} to somewhere MSVC +can see. +@end enumerate + +@item Libav has been tested with Visual Studio 2010 and 2012, Pro and Express. +Anything else is not officially supported. + +@end itemize + +@subsection Using shared libraries built with MinGW in Visual Studio + +Currently, if you want to build shared libraries on Windows, you need to +use MinGW. This is how to create DLL and LIB files that are compatible with MSVC++: