Changes between Version 7 and Version 8 of CompilationGuide/WinRT


Ignore:
Timestamp:
Apr 24, 2015, 7:10:35 AM (4 years ago)
Author:
timargo
Comment:

Add build instructions targeting Windows 10 Universal App Platform

Legend:

Unmodified
Added
Removed
Modified
  • CompilationGuide/WinRT

    v7 v8  
    33[[PageOutline(2)]]
    44
    5 FFmpeg libraries can be built for and used with '''Windows Store 8.1''' and '''Windows Phone 8.1''' apps development using MSVC 2013 (Update 3 RTM or newer). The guide below provides build instruction for all supported target configurations (platform & architecture). Each configuration requires distinct set of tools, environment variables, and configure options outlined in each section below. It concludes with some practical and potentially non-obvious information for consuming the FFmpeg DLLs from your app.
     5FFmpeg libraries can be built and used for Windows Apps development targeting '''Windows 10''', '''Windows 8.1''', and '''Windows Phone 8.1'''. The guide below provides build instruction for all supported target configurations (platform & architecture). Each configuration requires distinct set of tools, environment variables, and configure options outlined in each section below. It concludes with some practical and potentially non-obvious information for consuming the FFmpeg DLLs from your app.
    66
    77----
     
    1111=== Prerequisites ===
    1212
    13 * [http://www.visualstudio.com/downloads/download-visual-studio-vs Microsoft Visual Studio 2013] (use MSVC 2013 Update 3 RTM or newer)
     13* For Windows 10: [https://www.visualstudio.com/downloads/visual-studio-2015-ctp-vs Microsoft Visual Studio 2015] & [http://blogs.windows.com/buildingapps/2015/03/23/windows-10-developer-tooling-preview-now-available-to-windows-insiders/ Windows 10 SDK] (tested with Visual Studio 2015 CTP6)
     14* For Windows 8.1: [http://www.visualstudio.com/downloads/download-visual-studio-vs Microsoft Visual Studio 2013] (use MSVC 2013 Update 3 RTM or newer)
    1415* [http://msys2.github.io/ MSYS2] (GNU Make environment)
    1516* [http://yasm.tortall.net/ YASM] (x86 assembly code compiler)
    1617* [https://github.com/FFmpeg/gas-preprocessor gas-preprocessor.pl] (ARM assembly pre-processor)
    1718
     19[=#Windows10Setup]
     20=== Windows 10 Setup ===
     21
     22Download and install [https://www.visualstudio.com/downloads/visual-studio-2015-ctp-vs Microsoft Visual Studio 2015] and [http://blogs.windows.com/buildingapps/2015/03/23/windows-10-developer-tooling-preview-now-available-to-windows-insiders/ Windows 10 SDK] on a Windows 10 machine.
     23
     24Once the setup are completed, run the `reg query` command below to retrieve the '''Windows 10 SDK version''' to be used later.
     25
     26{{{
     27reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0" /v "ProductVersion"
     28}}}
     29
     30In the example query result below, the installed Windows 10 SDK version is `10.0.10030`. This version is to be set as `UCRTSdkVer` environment variable when setting up FFmpeg build command prompt.
     31
     32{{{
     33HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0
     34    ProductVersion    REG_SZ    10.0.10030
     35}}}
     36
     37=== Windows 8.1 Setup ===
     38
     39Download and install [http://www.visualstudio.com/downloads/download-visual-studio-vs Microsoft Visual Studio 2013] on a Windows 8.1 machine
     40
    1841=== MSYS2 Setup ===
    1942
     
    5679}}}
    5780
    58 Open MSYS2 shell from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
     81Open '''MSYS2 Shell''' from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
    5982{{{
    6083C:\msys64\msys2_shell.bat
     
    6487{{{
    6588$ which cl
    66 /c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/BIN/x86_ARM/cl
     89/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/x86_ARM/cl
    6790
    6891$ which link
    69 /c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/BIN/x86_ARM/link
     92/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/x86_ARM/link
    7093
    7194$ which armasm
    72 /c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/BIN/x86_ARM/armasm
     95/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/x86_ARM/armasm
    7396
    7497$ which yasm
     
    86109----
    87110
    88 To keep the source tree clean and the platforms separated, we will have the intermediate files go to the Output\<Platform>\<Architecture> folder under the FFmpeg source tree. We will also have the install files (the files necessary to link and use FFmpeg in your application) go to the Build\<Platform>\<Architecture> folder under the FFmpeg source tree.
    89 
    90 ----
    91 
    92 == Windows Store 8.1 x86 (Windows 8.1 Win32 in Visual Studio) ==
    93 
    94 Launch '''Developer Command Prompt for VS2013'''
    95 {{{
    96 Start Menu > Visual Studio 2013 (Start Menu Folder) > Visual Studio Tools > Developer Command Prompt for VS2013
    97 }}}
    98 
    99 Set the following environment variables in the launched command prompt above. These environment variables overwrite the default paths with correct target specific ones.
    100 {{{
    101 SET LIB=%VSINSTALLDIR%VC\lib\store;%VSINSTALLDIR%VC\atlmfc\lib;%WindowsSdkDir%lib\winv6.3\um\x86;;
    102 SET LIBPATH=%WindowsSdkDir%References\CommonConfiguration\Neutral;;%VSINSTALLDIR%VC\atlmfc\lib;%VSINSTALLDIR%VC\lib;
    103 SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%Include\um;%WindowsSdkDir%Include\shared;%WindowsSdkDir%Include\winrt;;
    104 }}}
    105 
    106 Open MSYS2 shell from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
    107 {{{
    108 C:\msys64\msys2_shell.bat
    109 }}}
    110 
    111 In your MSYS2 shell navigate to your cloned `FFmpeg` folder
    112 
    113 Invoke the following make commands
    114 {{{
    115 mkdir -p Output/Windows81/Win32
    116 cd Output/Windows81/Win32
     111To keep the source tree clean and the platforms separated, we will have the intermediate files go to the `Output\<Platform>\<Architecture>` folder under the `FFmpeg` source tree. We will also have the install files (the files necessary to link and use FFmpeg in your application) go to the `Build\<Platform>\<Architecture>` folder under the `FFmpeg` source tree.
     112
     113----
     114
     115== Windows 10 x86 ==
     116
     117Launch '''VS2015 x86 Native Tools Command Prompt'''. E.g.
     118{{{
     119C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 Native Tools Command Prompt
     120}}}
     121
     122Set the following environment variables in the launched command prompt above. Use the correct version of '''Windows 10 SDK version''' for `UCRTSdkVer` (see [#Windows10Setup Windows 10 Setup] on how to get the version)
     123{{{
     124SET UCRTSdkVer=10.0.10030.0
     125SET LIB=%VSINSTALLDIR%VC\lib\store;%VSINSTALLDIR%VC\atlmfc\lib;%UniversalCRTSdkDir%lib\winv10.0\ucrt\x86;;%UniversalCRTSdkDir%lib\%UCRTSdkVer%\um\x86;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x86;;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Lib\um\x86
     126SET LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib;%VSINSTALLDIR%VC\lib;
     127SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%UniversalCRTSdkDir%Include\ucrt;;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\um;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\shared;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\winrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Include\um;
     128}}}
     129
     130Open '''MSYS2 Shell''' from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
     131{{{
     132C:\msys64\msys2_shell.bat
     133}}}
     134
     135In your MSYS2 shell navigate to your cloned `FFmpeg` folder. E.g.
     136{{{
     137cd /c/ffmpeg
     138}}}
     139
     140Invoke the following make commands
     141{{{
     142mkdir -p Output/Windows10/Win32
     143
     144cd Output/Windows10/Win32
     145
    117146../../../configure \
    118147--toolchain=msvc \
     
    123152--enable-cross-compile \
    124153--target-os=win32 \
    125 --extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP -D_WIN32_WINNT=0x0603" \
    126 --extra-ldflags="-winmd -appcontainer" \
    127 --prefix=../../../Build/Windows81/Win32
    128 
    129 make
    130 
    131 make install
    132 }}}
    133 
    134 Generated libraries can be found in `Build/Windows81/Win32` folder specified in `--prefix` option above
    135 
    136 ----
    137 
    138 == Windows Store 8.1 x64 (Windows 8.1 x64 in Visual Studio) ==
    139 
    140 Launch '''VS2013 x64 Cross Tools Command Prompt'''
    141 {{{
    142 Start Menu > Visual Studio 2013 (Start Menu Folder) > Visual Studio Tools > VS2013 x64 Cross Tools Command Prompt
    143 }}}
    144 
    145 Set the following environment variables in the launched command prompt above. These environment variables overwrite the default paths with correct target specific ones.
    146 {{{
    147 SET LIB=%VSINSTALLDIR%VC\lib\store\amd64;%VSINSTALLDIR%VC\atlmfc\lib\amd64;%WindowsSdkDir%lib\winv6.3\um\x64;;
    148 SET LIBPATH=%WindowsSdkDir%References\CommonConfiguration\Neutral;;%VSINSTALLDIR%VC\atlmfc\lib\amd64;%VSINSTALLDIR%VC\lib\amd64;
    149 SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%Include\um;%WindowsSdkDir%Include\shared;%WindowsSdkDir%Include\winrt;;
    150 }}}
    151 
    152 Open MSYS2 shell from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
    153 {{{
    154 C:\msys64\msys2_shell.bat
    155 }}}
    156 
    157 In your MSYS2 shell navigate to your cloned `FFmpeg` folder
    158 
    159 Invoke the following make commands
    160 {{{
    161 mkdir -p Output/Windows81/x64
    162 cd Output/Windows81/x64
     154--extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WIN32_WINNT=0x0A00" \
     155--prefix=../../../Build/Windows10/Win32
     156
     157make
     158
     159make install
     160}}}
     161
     162Generated libraries can be found in `Build/Windows10/Win32` folder specified in `--prefix` option above
     163
     164----
     165
     166== Windows 10 x64 ==
     167
     168Launch '''VS2015 x86 x64 Cross Tools Command Prompt'''. E.g.
     169{{{
     170C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 x64 Cross Tools Command Prompt
     171}}}
     172
     173Set the following environment variables in the launched command prompt above. Use the correct version of '''Windows 10 SDK version''' for `UCRTSdkVer` (see [#Windows10Setup Windows 10 Setup] on how to get the version)
     174{{{
     175SET UCRTSdkVer=10.0.10030.0
     176SET LIB=%VSINSTALLDIR%VC\lib\store\amd64;%VSINSTALLDIR%VC\atlmfc\lib\amd64;%UniversalCRTSdkDir%lib\winv10.0\ucrt\x64;;%UniversalCRTSdkDir%lib\%UCRTSdkVer%\um\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x64;;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Lib\um\x64
     177SET LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib\amd64;%VSINSTALLDIR%VC\lib\amd64;
     178SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%UniversalCRTSdkDir%Include\ucrt;;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\um;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\shared;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\winrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Include\um;
     179}}}
     180
     181Open '''MSYS2 Shell''' from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
     182{{{
     183C:\msys64\msys2_shell.bat
     184}}}
     185
     186In your MSYS2 shell navigate to your cloned `FFmpeg` folder. E.g.
     187{{{
     188cd /c/ffmpeg
     189}}}
     190
     191Invoke the following make commands
     192{{{
     193mkdir -p Output/Windows10/x64
     194
     195cd Output/Windows10/x64
     196
    163197../../../configure \
    164198--toolchain=msvc \
     
    169203--enable-cross-compile \
    170204--target-os=win32 \
    171 --extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP -D_WIN32_WINNT=0x0603" \
    172 --extra-ldflags="-winmd -appcontainer" \
    173 --prefix=../../../Build/Windows81/x64
    174 
    175 make
    176 
    177 make install
    178 }}}
    179 
    180 Generated libraries can be found in `Build/Windows81/x64` folder specified in `--prefix` option above
    181 
    182 ----
    183 
    184 == Windows Store 8.1 ARM (Windows 8.1 ARM in Visual Studio) ==
    185 
    186 Launch '''VS2013 ARM Cross Tools Command Prompt'''
    187 {{{
    188 Start Menu > Visual Studio 2013 (Start Menu Folder) > Visual Studio Tools > VS2013 ARM Cross Tools Command Prompt
    189 }}}
    190 
    191 Set the following environment variables in the launched command prompt above. These environment variables overwrite the default paths with correct target specific ones.
    192 {{{
    193 SET LIB=%VSINSTALLDIR%VC\lib\store\ARM;%VSINSTALLDIR%VC\atlmfc\lib\ARM;%WindowsSdkDir%lib\winv6.3\um\arm;;
    194 SET LIBPATH=%WindowsSdkDir%References\CommonConfiguration\Neutral;;%VSINSTALLDIR%VC\atlmfc\lib\ARM;%VSINSTALLDIR%VC\lib\ARM;
    195 SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%Include\um;%WindowsSdkDir%Include\shared;%WindowsSdkDir%Include\winrt;;
    196 }}}
    197 
    198 Open MSYS2 shell from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
    199 {{{
    200 C:\msys64\msys2_shell.bat
    201 }}}
    202 
    203 In your MSYS2 shell navigate to your cloned `FFmpeg` folder
    204 
    205 Invoke the following make commands
    206 {{{
    207 mkdir -p Output/Windows81/ARM
    208 cd Output/Windows81/ARM
     205--extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WIN32_WINNT=0x0A00" \
     206--prefix=../../../Build/Windows10/x64
     207
     208make
     209
     210make install
     211}}}
     212
     213Generated libraries can be found in `Build/Windows10/x64` folder specified in `--prefix` option above
     214
     215----
     216
     217== Windows 10 ARM ==
     218
     219Launch '''VS2015 x86 ARM Cross Tools Command Prompt'''. E.g.
     220{{{
     221C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 ARM Cross Tools Command Prompt
     222}}}
     223
     224Set the following environment variables in the launched command prompt above. Use the correct version of '''Windows 10 SDK version''' for `UCRTSdkVer` (see [#Windows10Setup Windows 10 Setup] on how to get the version)
     225{{{
     226SET UCRTSdkVer=10.0.10030.0
     227SET LIB=%VSINSTALLDIR%VC\lib\store\ARM;%VSINSTALLDIR%VC\atlmfc\lib\ARM;%UniversalCRTSdkDir%lib\winv10.0\ucrt\arm;;%UniversalCRTSdkDir%lib\%UCRTSdkVer%\um\arm;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\arm;;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Lib\um\arm
     228SET LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib\ARM;%VSINSTALLDIR%VC\lib\ARM;
     229SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%UniversalCRTSdkDir%Include\ucrt;;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\um;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\shared;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\winrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Include\um;
     230}}}
     231
     232Open '''MSYS2 Shell''' from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
     233{{{
     234C:\msys64\msys2_shell.bat
     235}}}
     236
     237In your MSYS2 shell navigate to your cloned `FFmpeg` folder. E.g.
     238{{{
     239cd /c/ffmpeg
     240}}}
     241
     242Invoke the following make commands
     243{{{
     244mkdir -p Output/Windows10/ARM
     245
     246cd Output/Windows10/ARM
     247
    209248../../../configure \
    210249--toolchain=msvc \
     
    218257--enable-cross-compile \
    219258--target-os=win32 \
    220 --extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP -D_WIN32_WINNT=0x0603 -D__ARM_PCS_VFP" \
    221 --extra-ldflags="-MACHINE:ARM -winmd -appcontainer" \
    222 --prefix=../../../Build/Windows81/ARM
    223 
    224 make
    225 
    226 make install
    227 }}}
    228 
    229 Generated libraries can be found in `Build/Windows81/ARM` folder specified in `--prefix` option above
    230 
    231 ----
    232 
    233 == Windows Phone 8.1 x86 (Windows Phone 8.1 Win32 Emulator in Visual Studio) ==
     259--extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WIN32_WINNT=0x0A00 -D__ARM_PCS_VFP" \
     260--prefix=../../../Build/Windows10/ARM
     261
     262make
     263
     264make install
     265}}}
     266
     267Generated libraries can be found in `Build/Windows10/ARM` folder specified in `--prefix` option above
     268
     269There is currently a bug on Visual Studio 2015 CTP 6 ARM compiler that prevent the mjpeg source code to be compiled. As a workaround, disable mjpeg by adding the following options to configure command above.
     270{{{
     271--disable-decoder=avrn \
     272--disable-decoder=mjpeg \
     273--disable-encoder=mjpeg \
     274}}}
     275
     276----
     277
     278== Windows Store 8.1 x86 (Windows 8.1 Win32 in Visual Studio) ==
    234279
    235280Launch '''Developer Command Prompt for VS2013'''
     
    240285Set the following environment variables in the launched command prompt above. These environment variables overwrite the default paths with correct target specific ones.
    241286{{{
    242 SET LIB=%VSINSTALLDIR%VC\lib\store;%VSINSTALLDIR%VC\atlmfc\lib;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\lib\x86;;
    243 SET LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib;%VSINSTALLDIR%VC\lib
    244 SET INCLUDE=%VSINSTALLDIR%VC\INCLUDE;%VSINSTALLDIR%VC\ATLMFC\INCLUDE;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\abi;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\mincore;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\minwin;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\wrl;
    245 }}}
    246 
    247 Open MSYS2 shell from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
    248 {{{
    249 C:\msys64\msys2_shell.bat
    250 }}}
    251 
    252 In your MSYS2 shell navigate to your cloned `FFmpeg` folder
    253 
    254 Invoke the following make commands
    255 {{{
    256 mkdir -p Output/WindowsPhone81/Win32
    257 cd Output/WindowsPhone81/Win32
     287SET LIB=%VSINSTALLDIR%VC\lib\store;%VSINSTALLDIR%VC\atlmfc\lib;%WindowsSdkDir%lib\winv6.3\um\x86;;
     288SET LIBPATH=%WindowsSdkDir%References\CommonConfiguration\Neutral;;%VSINSTALLDIR%VC\atlmfc\lib;%VSINSTALLDIR%VC\lib;
     289SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%Include\um;%WindowsSdkDir%Include\shared;%WindowsSdkDir%Include\winrt;;
     290}}}
     291
     292Open '''MSYS2 Shell''' from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
     293{{{
     294C:\msys64\msys2_shell.bat
     295}}}
     296
     297In your MSYS2 shell navigate to your cloned `FFmpeg` folder. E.g.
     298{{{
     299cd /c/ffmpeg
     300}}}
     301
     302Invoke the following make commands
     303{{{
     304mkdir -p Output/Windows81/Win32
     305cd Output/Windows81/Win32
    258306../../../configure \
    259307--toolchain=msvc \
     
    264312--enable-cross-compile \
    265313--target-os=win32 \
    266 --extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP -D_WIN32_WINNT=0x0603" \
    267 --extra-ldflags="-subsystem:console -opt:ref WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib -NODEFAULTLIB:kernel32.lib -NODEFAULTLIB:ole32.lib" \
    268 --prefix=../../../Build/WindowsPhone81/Win32
    269 
    270 make
    271 
    272 make install
    273 }}}
    274 
    275 Generated libraries can be found in `Build/WindowsPhone81/Win32` folder specified in `--prefix` option above
    276 
    277 ----
    278 
    279 == Windows Phone 8.1 ARM (Windows Phone 8.1 ARM Device in Visual Studio) ==
     314--extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP -D_WIN32_WINNT=0x0603" \
     315--extra-ldflags="-winmd -appcontainer" \
     316--prefix=../../../Build/Windows81/Win32
     317
     318make
     319
     320make install
     321}}}
     322
     323Generated libraries can be found in `Build/Windows81/Win32` folder specified in `--prefix` option above
     324
     325----
     326
     327== Windows Store 8.1 x64 (Windows 8.1 x64 in Visual Studio) ==
     328
     329Launch '''VS2013 x64 Cross Tools Command Prompt'''
     330{{{
     331Start Menu > Visual Studio 2013 (Start Menu Folder) > Visual Studio Tools > VS2013 x64 Cross Tools Command Prompt
     332}}}
     333
     334Set the following environment variables in the launched command prompt above. These environment variables overwrite the default paths with correct target specific ones.
     335{{{
     336SET LIB=%VSINSTALLDIR%VC\lib\store\amd64;%VSINSTALLDIR%VC\atlmfc\lib\amd64;%WindowsSdkDir%lib\winv6.3\um\x64;;
     337SET LIBPATH=%WindowsSdkDir%References\CommonConfiguration\Neutral;;%VSINSTALLDIR%VC\atlmfc\lib\amd64;%VSINSTALLDIR%VC\lib\amd64;
     338SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%Include\um;%WindowsSdkDir%Include\shared;%WindowsSdkDir%Include\winrt;;
     339}}}
     340
     341Open '''MSYS2 Shell''' from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
     342{{{
     343C:\msys64\msys2_shell.bat
     344}}}
     345
     346In your MSYS2 shell navigate to your cloned `FFmpeg` folder. E.g.
     347{{{
     348cd /c/ffmpeg
     349}}}
     350
     351Invoke the following make commands
     352{{{
     353mkdir -p Output/Windows81/x64
     354cd Output/Windows81/x64
     355../../../configure \
     356--toolchain=msvc \
     357--disable-programs \
     358--disable-dxva2 \
     359--arch=x86_64 \
     360--enable-shared \
     361--enable-cross-compile \
     362--target-os=win32 \
     363--extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP -D_WIN32_WINNT=0x0603" \
     364--extra-ldflags="-winmd -appcontainer" \
     365--prefix=../../../Build/Windows81/x64
     366
     367make
     368
     369make install
     370}}}
     371
     372Generated libraries can be found in `Build/Windows81/x64` folder specified in `--prefix` option above
     373
     374----
     375
     376== Windows Store 8.1 ARM (Windows 8.1 ARM in Visual Studio) ==
    280377
    281378Launch '''VS2013 ARM Cross Tools Command Prompt'''
     
    286383Set the following environment variables in the launched command prompt above. These environment variables overwrite the default paths with correct target specific ones.
    287384{{{
    288 SET LIB=%VSINSTALLDIR%VC\lib\store\ARM;%VSINSTALLDIR%VC\atlmfc\lib\ARM;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\lib\arm;;
    289 SET LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib\ARM;%VSINSTALLDIR%VC\lib\ARM
    290 SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\abi;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\mincore;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\minwin;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\wrl;
    291 }}}
    292 
    293 Open MSYS2 shell from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
    294 {{{
    295 C:\msys64\msys2_shell.bat
    296 }}}
    297 
    298 In your MSYS2 shell navigate to your cloned `FFmpeg` folder
    299 
    300 Invoke the following make commands
    301 {{{
    302 mkdir -p Output/WindowsPhone81/ARM
    303 cd Output/WindowsPhone81/ARM
     385SET LIB=%VSINSTALLDIR%VC\lib\store\ARM;%VSINSTALLDIR%VC\atlmfc\lib\ARM;%WindowsSdkDir%lib\winv6.3\um\arm;;
     386SET LIBPATH=%WindowsSdkDir%References\CommonConfiguration\Neutral;;%VSINSTALLDIR%VC\atlmfc\lib\ARM;%VSINSTALLDIR%VC\lib\ARM;
     387SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%Include\um;%WindowsSdkDir%Include\shared;%WindowsSdkDir%Include\winrt;;
     388}}}
     389
     390Open '''MSYS2 Shell''' from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
     391{{{
     392C:\msys64\msys2_shell.bat
     393}}}
     394
     395In your MSYS2 shell navigate to your cloned `FFmpeg` folder. E.g.
     396{{{
     397cd /c/ffmpeg
     398}}}
     399
     400Invoke the following make commands
     401{{{
     402mkdir -p Output/Windows81/ARM
     403cd Output/Windows81/ARM
    304404../../../configure \
    305405--toolchain=msvc \
     
    313413--enable-cross-compile \
    314414--target-os=win32 \
     415--extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP -D_WIN32_WINNT=0x0603 -D__ARM_PCS_VFP" \
     416--extra-ldflags="-MACHINE:ARM -winmd -appcontainer" \
     417--prefix=../../../Build/Windows81/ARM
     418
     419make
     420
     421make install
     422}}}
     423
     424Generated libraries can be found in `Build/Windows81/ARM` folder specified in `--prefix` option above
     425
     426----
     427
     428== Windows Phone 8.1 x86 (Windows Phone 8.1 Win32 Emulator in Visual Studio) ==
     429
     430Launch '''Developer Command Prompt for VS2013'''
     431{{{
     432Start Menu > Visual Studio 2013 (Start Menu Folder) > Visual Studio Tools > Developer Command Prompt for VS2013
     433}}}
     434
     435Set the following environment variables in the launched command prompt above. These environment variables overwrite the default paths with correct target specific ones.
     436{{{
     437SET LIB=%VSINSTALLDIR%VC\lib\store;%VSINSTALLDIR%VC\atlmfc\lib;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\lib\x86;;
     438SET LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib;%VSINSTALLDIR%VC\lib
     439SET INCLUDE=%VSINSTALLDIR%VC\INCLUDE;%VSINSTALLDIR%VC\ATLMFC\INCLUDE;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\abi;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\mincore;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\minwin;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\wrl;
     440}}}
     441
     442Open '''MSYS2 Shell''' from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
     443{{{
     444C:\msys64\msys2_shell.bat
     445}}}
     446
     447In your MSYS2 shell navigate to your cloned `FFmpeg` folder. E.g.
     448{{{
     449cd /c/ffmpeg
     450}}}
     451
     452Invoke the following make commands
     453{{{
     454mkdir -p Output/WindowsPhone81/Win32
     455cd Output/WindowsPhone81/Win32
     456../../../configure \
     457--toolchain=msvc \
     458--disable-programs \
     459--disable-dxva2 \
     460--arch=x86 \
     461--enable-shared \
     462--enable-cross-compile \
     463--target-os=win32 \
     464--extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP -D_WIN32_WINNT=0x0603" \
     465--extra-ldflags="-subsystem:console -opt:ref WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib -NODEFAULTLIB:kernel32.lib -NODEFAULTLIB:ole32.lib" \
     466--prefix=../../../Build/WindowsPhone81/Win32
     467
     468make
     469
     470make install
     471}}}
     472
     473Generated libraries can be found in `Build/WindowsPhone81/Win32` folder specified in `--prefix` option above
     474
     475----
     476
     477== Windows Phone 8.1 ARM (Windows Phone 8.1 ARM Device in Visual Studio) ==
     478
     479Launch '''VS2013 ARM Cross Tools Command Prompt'''
     480{{{
     481Start Menu > Visual Studio 2013 (Start Menu Folder) > Visual Studio Tools > VS2013 ARM Cross Tools Command Prompt
     482}}}
     483
     484Set the following environment variables in the launched command prompt above. These environment variables overwrite the default paths with correct target specific ones.
     485{{{
     486SET LIB=%VSINSTALLDIR%VC\lib\store\ARM;%VSINSTALLDIR%VC\atlmfc\lib\ARM;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\lib\arm;;
     487SET LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib\ARM;%VSINSTALLDIR%VC\lib\ARM
     488SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\abi;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\mincore;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\minwin;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\wrl;
     489}}}
     490
     491Open '''MSYS2 Shell''' from the command prompt above (use the correct drive and location of your MSYS2 installation). Note that the command shell above will close and it may take a while for the MSYS2 shell to launch.
     492{{{
     493C:\msys64\msys2_shell.bat
     494}}}
     495
     496In your MSYS2 shell navigate to your cloned `FFmpeg` folder. E.g.
     497{{{
     498cd /c/ffmpeg
     499}}}
     500
     501Invoke the following make commands
     502{{{
     503mkdir -p Output/WindowsPhone81/ARM
     504cd Output/WindowsPhone81/ARM
     505../../../configure \
     506--toolchain=msvc \
     507--disable-programs \
     508--disable-dxva2 \
     509--arch=arm \
     510--as=armasm \
     511--cpu=armv7 \
     512--enable-thumb \
     513--enable-shared \
     514--enable-cross-compile \
     515--target-os=win32 \
    315516--extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP -D_WIN32_WINNT=0x0603 -D__ARM_PCS_VFP" \
    316517--extra-ldflags="-MACHINE:ARM -subsystem:console -opt:ref WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib -NODEFAULTLIB:kernel32.lib -NODEFAULTLIB:ole32.lib" \
     
    325526
    326527----
     528
    327529== Windows Store Certification, File I/O, and Other Details ==
    328530
    329 FFmpeg is an excellent alternative to Windows Media Foundation, which supports a small fraction of the codecs that FFmpeg has. Fortunately, 
     531FFmpeg is an excellent alternative to Windows Media Foundation, which supports a small fraction of the codecs that FFmpeg has. Fortunately,
    330532FFmpeg does not use any prohibited Windows or CRT APIs, and apps linked to the DLLs built with this method pass the latest Windows App Certification Kit. However, there are important things to remember.
    331533
    332534First, don't forget to make sure your app package includes all the necessary FFmpeg DLLs in the root folder. In your Visual C++ project, you should include links to the FFmpeg DLLs in the root project folder, making sure to set "Build Action" to "Content" and "Copy to Output Directory" to "Copy Always". It is not enough just to link to the import libraries. You will fail certification if you require your users to install the FFmpeg DLLs separately.
    333535
    334 You will also need to supply a custom file I/O context to any `AVFormatContext` rather than relying on `avio_xxx` functions, because the standard I/O functions utilize CRT I/O that is not supported in WinRT. (You won't fail certification, but your app will be unable to access the file specified in the `AVFormatContext.filename` member, unless potentially it is located in the app's local storage). The file I/O context needs to be initialized to point to your `read`, `write`, and `seek` functions, with the `opaque` member pointing to a `struct` containing an `IRandomAccessStream^` that you obtain when opening a file using proper WinRT IO calls in the `Windows::Storage` namespace. (You need a `struct` to hold the `IRandomAccessStream^`, since you cannot cast a `void*` to a ref handle). Your `read`, `write`, and `seek` functions should cast the `void* opaque` argument to the `struct*` you define, and then use the `IRandomAccessStream^` for all I/O. 
     536You will also need to supply a custom file I/O context to any `AVFormatContext` rather than relying on `avio_xxx` functions, because the standard I/O functions utilize CRT I/O that is not supported in WinRT. (You won't fail certification, but your app will be unable to access the file specified in the `AVFormatContext.filename` member, unless potentially it is located in the app's local storage). The file I/O context needs to be initialized to point to your `read`, `write`, and `seek` functions, with the `opaque` member pointing to a `struct` containing an `IRandomAccessStream^` that you obtain when opening a file using proper WinRT IO calls in the `Windows::Storage` namespace. (You need a `struct` to hold the `IRandomAccessStream^`, since you cannot cast a `void*` to a ref handle). Your `read`, `write`, and `seek` functions should cast the `void* opaque` argument to the `struct*` you define, and then use the `IRandomAccessStream^` for all I/O.
    335537
    336538Since FFmpeg I/O calls are synchronous, but the `IRandomAccessStream` members are all asynchronous, you will need to utilize `create_task` and `wait()` on all I/O calls in your IO context implementation functions. Note that this necessitates that any FFmpeg functions utilizing file I/O be executed on a WORKER thread, as WinRT will generate an exception if you use `wait()` in the UI thread. The best solution here is to create WinRT-friendly wrapper functions of the major FFmpeg functions you will utilize, by using the `concurrency::create_async` function, for example:
     
    347549
    348550Alternatively, if you don't want to use Windows Runtime extensions, and don't mind COM, you can use the Windows 8-API function `CreateStreamOverRandomAccessStream`, which gives you an `IStream*` COM interface from an `IRandomAccessStream^`, utilizes synchronous I/O, and can be passed as the `void* opaque` member of the IO context. The `IStream` I/O calls are easier to use with C++ since they support direct pointer buffer access (you don't have to deal with `IBuffer`) and more closely correspond to the functions required in `AVIOContext`. However, you should still make sure to wrap any code that utilizes file I/O in a background thread, as excessive blocking of the UI does violate Windows Store guidelines and may cause your app to be terminated at runtime.
    349