Vs2013 compiling ffmpeg

Because VS2013 support C99, so, you can directly use VS2013 for FFMPEG compilation and debugging, and no longer use Eclipse toss. Referring to others, the record is as follows:

Specific steps:
1. Download FFMPEG source code, download address: http://ffmpeg.zeranoe.com/builds/ or http://ffmpeg.org/download.html

2. Download the MinGW installer, download address: http://www.mingw.org/ or http://sourceforge.net/projects/mingw/files/latest/download?Source =files install after download, click run after install, mark the following items:

Then, under the Installation menu, click Apply Changes (mingw32-gcc-g++ is not selected);

Download msys2 http://sourceforge.net/projects/msys2/ download after installation to the mingw/msys2/directory

Download YASM at http://yasm.tortall.net/; Please do not download the VS version, but download the 64-bit version. After downloading, rename it to yasm.exe and copy it to the usr/bin directory of msys2.

4. Configuration C:/MinGW msys/1.0/msys. Bat, in the front of this file (@ echo off after) add a line the following contents:
(The same is true for MSYS2)
Call “D:\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat”; call “D:\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat”

5. Rename the C:/MinGW msys/1.0/bin/link. Exe for link_renamed. Exe (in accordance with the actual installation path) choice, this step is to prevent the link. Exe and vc link. Exe conflict, after the completion of the compilation can modify the back; Vc /bin link. Exe lib. Exe.

6. Configure compilation, double click msys.bat, go to the FFMPEG source code root directory, can run./configure –help to view the compilation configuration options, I used the option:
Static library:./configure –enable-static –prefix=./vs2013_build –enable-debug –toolchain= MSVC
Dynamic library:./configure –enable-shared –prefix=./vs2013_build –enable-debug –toolchain= MSVC

— — — — — — — — — — — — — — — — — — note:
The default is enable-yasm, and you can –disable-asm disable all assembly optimizations if you don’t want them
For libraries that generate release mode, you can –disable-debug to remove the debug message
Static library:./configure –enable-static –prefix=./vs2013_build_release –disable-debug –toolchain= MSVC — enable-memalligate-hack
For libraries that generate Debug mode, it seems that the top approach is fine, but to be safe in order to step into any function, set it as follows:
./configure –enable-static –prefix=./vs2013_build_noyasm –enable-debug –toolchain= MSVC –disable-yasm — disable-memalloce-hack
—————–

Wait for the configuration to return;

7. Type make all to compile;
8. Type make install.

If you have any problems, make for msys2 can enter the msys environment, run the pacman -s make may refer to http://m.oschina.net/blog/363658

The generated header files and libraries are in the vs2013_build directory under the FFMPEG source code.

Create a project FFMEPG_TEST (static)
Find a file in share/example, such as avio_reading.c, and place it in your project
Add the include directory and lib directory: C++->; Conventional – & gt; ADD INCLUDE DIRECTORY ADD INCLUDE LINKER ADD LIB
Add to lib:
advapi32.lib; Secur32.lib; ws2_32.lib; libavcodec.a; libavdevice.a; libavfilter.a; libavformat.a; libavutil.a; libswresample.a; libswscale.a;

———————————————–
Inline error is encountered during compilation because VS2013 uses its own _inline
#define inline _inline in a file

Then, the default library “MSVCRTD” conflicts with other libraries
Solution:
Properties – C++->; Code Generation -> runtime changed to multithreading /MT
/NODEFAULTLIB:libcmt.lib: /NODEFAULTLIB:libcmt.lib: /NODEFAULTLIB:libcmt.lib: /NODEFAULTLIB:libcmt.lib

The avcodec_alloc_frame() function received an error

Replace avcodec_alloc_frame() with av_frame_alloc().

Compile successfully

The scheme used for compiling 64-bit is MSYS2 + MINGW64
After installing MSYS2, in the directory
Pacman-S make GCC diffutils mingw64-x86_64-toolchain
Rename /usr/bin/link.exe to /usr/bin/link.bak to avoid conflicts with MSVC’s link.exe.

04 configuration msys2
04.01 edit the C:/msys64/msys2_shell. CMD,
Rem set MSYS2_PATH_TYPE=inherit: set MSYS2_PATH_TYPE=inherit
Open the MSYS2 window associated with VS2015
In the Command Prompt window, type:
# Switch to C: /msys64 directory CD C: /msys64 # Switch to VS2016 64-bit environment C:\
PR
Ogram Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat # Open mingw64 window msys2_shel.cmd-mingw64 of msys2
04.03 Check tool components
/ C/ Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/amd64/cl /c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/amd64/link /usr/ BIN/ yasm /usr/ BIN/ CPP

Modify the MSYS2 window code page to GBK to avoid displaying garbled code at compile time.
Right-click on the window, select the [Options] menu, select [Text], locale select: zh_CN, Character set select GBK. –arch=x86_64 make

After configuring the config, it may still be x86, open the config file, and change the corresponding value to 0


Read More: