Changes between Version 5 and Version 6 of CompilationGuide/MSVC


Ignore:
Timestamp:
Jul 8, 2015, 10:52:34 PM (4 years ago)
Author:
llogan
Comment:

attempt to introduce some formatting for this mess

Legend:

Unmodified
Added
Removed
Modified
  • CompilationGuide/MSVC

    v5 v6  
    1 It's fairly simple to build ffmpeg on Windows with visual studio. The official guide found on this page is quite clear, but a little bit out-of-date.
    2 [https://www.ffmpeg.org/platform.html#Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows]
    31
    4 I experienced few minor issues while building ffmpeg myself. I decided to document them here.
     2
     3
     4{{{#!comment
     5Note to the author: The formatting and layout of this page is terrible. Please fix. Refer to WikiFormatting.
     6}}}
     7
     8
     9
     10
     11
     12It's fairly simple to build `ffmpeg` on Windows with Visual Studio. The [https://www.ffmpeg.org/platform.html#Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows official guide] is quite clear, but a little bit out-of-date.
    513
    614FFmpeg can be built with MSVC 2012 or earlier using a C99-to-C89 conversion utility and wrapper, or with MSVC 2013 natively.
     
    816You will need the following prerequisites:
    917
    10 1. C99-to-C89 Converter & Wrapper (if using MSVC 2012 or earlier)
    11 [https://github.com/libav/c99-to-c89/]
    12 
    13 2. msinttypes (if using MSVC 2012 or earlier)
    14 [http://code.google.com/p/msinttypes/]
    15 
    16 3. MSYS
    17 [http://www.mingw.org/]
    18 
    19 4. YASM
    20 [http://yasm.tortall.net/]
     18* [https://github.com/libav/c99-to-c89/ C99-to-C89 Converter & Wrapper] if using MSVC 2012 or earlier.
     19* [http://code.google.com/p/msinttypes/ msinttypes] if using MSVC 2012 or earlier.
     20* [http://www.mingw.org/ MSYS]
     21* [http://yasm.tortall.net/ YASM]
    2122
    2223
    23 First, you need to unzip and copy 1,2,4 into a folder, for example, c:\c99
    24 Then, you need to add the folder c:\c99 into your PATH environment variable.
    25 Rename yasm-1.2.0-win64.exe (or the yasm executable you will use) to yasm.exe
    26 Finally, create an INCLUDE environment variable, and point it to c:\99, this is the location where the compiler will find inttypes.h
     24First, you need to unzip and copy the prerequisites into a folder, for example, `c:\c99`.
    2725
    28 ''If it complains of "MSVCR100.dll not found" when running yasm, install the microsoft 2010 VC [http://www.faqforge.com/windows/fix-the-program-cant-start-because-msvcr100-dll-is-missing-from-your-computer-error-on-windows/ redistributable]
    29 ''
     26Then, you need to add the folder `c:\c99` into your `PATH` environment variable.
    3027
    31 To set up a proper environment in MSYS, you need to run msys.bat from the Visual Studio or Intel Compiler command prompt.
     28Rename the yasm executable you will use to `yasm.exe`.
    3229
    33 Next, make sure any other headers and libs you want to use, such as zlib, are located in a spot that the compiler can see. Do so by modifying the LIB and INCLUDE environment variables to include the Windows-style paths to these directories. Alternatively, you can try and use the --extra-cflags/--extra-ldflags configure options.
     30Finally, create an `INCLUDE` environment variable, and point it to `c:\99`; this is the location where the compiler will find `inttypes.h`.
     31
     32{{{
     33#!div style="border: 1pt dotted; margin: 1em; background-color: #fffff9;"
     34'''Note:''' If it complains of `MSVCR100.dll not found` when running yasm, install the Microsoft 2010 VC [http://www.faqforge.com/windows/fix-the-program-cant-start-because-msvcr100-dll-is-missing-from-your-computer-error-on-windows/ redistributable].
     35}}}
     36
     37To set up a proper environment in MSYS, you need to run `msys.bat` from the Visual Studio or Intel Compiler command prompt.
     38
     39Next, make sure any other headers and libs you want to use, such as zlib, are located in a location that the compiler can see. Do so by modifying the `LIB` and `INCLUDE` environment variables to include the Windows-style paths to these directories. Alternatively, you can try and use the `--extra-cflags`/`--extra-ldflags` configure options.
    3440
    3541Finally, run:
    3642       
    3743For MSVC:
     44
     45{{{
    3846./configure --toolchain=msvc
    3947make
    4048make install
     49}}}
    4150
    4251or the following:
     52
     53{{{
    4354./configure --enable-asm --enable-yasm --arch=i386 --disable-ffserver --disable-avdevice --disable-swscale --disable-doc --disable-ffplay --disable-ffprobe --disable-ffmpeg --enable-shared --disable-static --disable-bzlib --disable-libopenjpeg --disable-iconv --disable-zlib --prefix=/c/ffmpeg --toolchain=msvc
     55}}}
    4456
    45 --enable-shared will generate the dynamic linked lib (dlls)
    4657
    47 ''you might see an error saying cl can't generate executable, this is because you installed the link.exe from msys. it conflicts with the link.exe of visual studio.
    48 ''
     58`--enable-shared` will generate the dynamic linked lib (dlls)
     59
     60{{{
     61#!div style="border: 1pt dotted; margin: 1em; background-color: #fffff9;"
     62'''Note:''' You might see an error saying cl can't generate executable; this is because you installed the `link.exe` from MSYS. It conflicts with the `link.exe` of Visual Studio.
     63}}}
    4964
    5065{{{
     
    5570}}}
    5671
    57 you can try "which link.exe" to verify if it is the case. if you see /bin/link.exe, then you can simply rm /bin/link.exe See here for details: [https://trac.ffmpeg.org/ticket/3203]
     72You can try `which link.exe` to verify if it is the case. If you see `/bin/link.exe`, then you can simply `rm /bin/link.exe`. For more info see [https://trac.ffmpeg.org/ticket/3203 #3203 Windows MSVC configure failed].
    5873
    59 the right link.exe should come from this location:
     74The right `link.exe` should come from this location:
    6075
     76{{{
    6177/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/BIN/link.exe
     78}}}
    6279
    63 you might see two problems when building ffmpeg:
    64 ''1. pr command not found:
    65 ''
     80You might see two problems when building `ffmpeg`:
    6681
    67 please take a look at here [http://creekcodes.blogspot.com/2011/02/msys-pr-not-found.html]
    68 basically pr.exe is removed from msys, you need to download it from here [http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/_obsolete/coreutils-5.97-MSYS-1.0.11-2/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2/download] and copy pr.exe to the msys/bin folder.
     821. `pr` command not found:
    6983
    70 ''2. the compiler might complain about redefinition issues of stdint.h, because both msinttypes and visual studio have stdint.h. I removed stdint.h from c:\c99 to let the compiler uses the one provided by visual studio.
    71 ''
     84A solution is posted at [http://creekcodes.blogspot.com/2011/02/msys-pr-not-found.html MSYS pr not found]. Basically, `pr.exe` is removed from MSYS. You need to [http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/_obsolete/coreutils-5.97-MSYS-1.0.11-2/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2/download download] it and copy `pr.exe` to the `msys/bin` folder.
    7285
    73 in the end of configuration, you might also see pkg-config not found issue. that won't affect compilation, you can ignore it. it is said that installing pkg-config to msys is kinda tiresome.
     862. The compiler might complain about redefinition issues of `stdint.h`, because both msinttypes and Visual Studio have `stdint.h`. I removed `stdint.h` from `c:\c99` to let the compiler uses the one provided by Visual Studio.
    7487
     88In the end of configuration, you might also see `pkg-config` not found issue. That won't affect compilation, you can ignore it. It is said that installing `pkg-config` to MSYS is kinda tiresome.
    7589
    7690How to build debug version?
    7791
    78 an example:
     92An example:
    7993
     94{{{
    8095$ ./configure --enable-asm --enable-yasm --disable-ffserver --disable-avdevice --disable-doc --disable-ffplay --disable-ffprobe --disable-ffmpeg --enable-shared --disable-static --disable-bzlib --disable-libopenjpeg --disable-iconv --disable-zlib --prefix=/c/ffmpeg --toolchain=msvc --arch=amd64 --extra-cflags="-MDd" --extra-ldflags="/NODEFAULTLIB:libcmt" --enable-debug
     96}}}