Compiled with vs2010 under Windows FFmpeg

Source: Internet
Author: User

Reprint from; http://q1q2q3q4q5q6ln.blog.163.com/blog/static/500794332014666536283/

(Note: Please be sure to read: Seven, PostScript add:)

FFmpeg is an open source multimedia library that is used very extensively.
Compiling ffmpeg under Linux is very simple, and compiling under Windows is not so easy. It is generally compiled using MinGW's gcc toolchain under Windows, since FFmpeg's export function is C-style, so the GCC-compiled lib can be linked by vs. However, the debug symbol of GCC is incompatible with the debug symbol for VS (*.pdb), so we do not use VS to develop ffmpeg-based programs to ffmpeg internal debug, which is not so friendly either for learning or engineering. Thus, the use of the same set of compilation system benefits a lot.
This blog post shows you how to compile ffmpeg under Windows with VS2010 and a ffmpeg-based chestnut from beginning to end. Also suitable for vs2012/vs2013 and so on.
Color= "#ff0000" > Note: Please do not use this blog method to try to VS2010 the following version of the compilation ffmpeg, I have tried to compile in vs2005, a variety of problems! The official also did not compile the test in the following version of VS2010.
First, download ffmpeg and third-party programs:
1,ffmpeg Official website: http://ffmpeg.org/
2,ffmpeg git address: git://source.ffmpeg.org/ffmpeg.git (Note: The clone code is set before the git command line!!!) : Git config--global core.autocrlf false)
3,mingw:http://www.mingw.org/, run the downloaded MinGW Installation Manager, which contains the Msys. Assuming the MinGW path is: D:/mingw after installation, the Msys path should be: D:/mingw/msys. Add: D:/mingw/bin and D:/mingw/msys/1.0/bin to the system path environment variable;
4,yasm:http://yasm.tortall.net/, changed to name Yasm.exe, copy to: D:/mingw/msys/1.0/bin directory;
/******************** if it is vs2013 +, the following two (5,6) do not need to be installed ***********************/
5,c99-to-c89:https://github.com/libav/c99-to-c89/downloads, copy C99conv.exe and C99wrap.exe to: D:/mingw/msys/1.0/bin Under the catalogue;
6,c99 header Files Inttypes.h and stdint.h:http://code.google.com/p/msinttypes/downloads/list, copy this two header files to: D:program files (x86) Microsoft Visual Studio 10.0VCinclude directory (self-modifying to its own installation directory);

Two, before compiling the settings:
1, copy: D/mingw/msys/1.0/msys.bat to the same directory, renamed as Msys_vs2010.bat, at the beginning of the Msys_vs2010.bat add: "Call" D:program Files (x86) Microsoft Visual Studio 10.0vcbinvcvars32.bat ";
2, rename D:/mingw/msys/1.0/bin/link.exe to Link_renamed.exe, this step is to prevent the Link.exe and VC link.exe conflict, after the completion of the compilation Remember to change back;
2. Open the Msys_vs2010.bat and switch to the FFmpeg directory.
So far, all the pre-compilation work has been done.

Three, configure the compilation:
1, Configuration: FFmpeg compilation configuration options are rich, please run "./configure--help > Ffmpegcfg.txt" to view its options. Here my options are:
Static library:./configure--enable-static--prefix=./vs2010_build--toolchain=msvc
Dynamic library:./configure--enable-shared--prefix=./vs2010_build--toolchain=msvc
2, compile: Make & make install;
3, change back renamed D:/mingw/msys/1.0/bin/link_renamed.exe to Link.exe.
Compile time is related to machine performance and may be slow.
At this point in the vs2010_build generated a compiled Ffmpe library, there are 4 directories, bin, include, Lib, share.
Four, a chestnut:
Ok,ffmpeg compiled successfully, let's end this compilation experience with a chestnut.
There are a number of examples under the Vs2010_build/share/ffmpeg/examples directory.
Let's just grab a avio_reading.c and drag it to our Test_ffmpeg project (VS2010), and remember to configure the include and LIB paths (very simply, not in detail).
link library join: ws2_32.lib;libavcodec.a;libavdevice.a;libavfilter.a;libavformat.a;libavutil.a;libswresample.a; Libswscale.a;
Compile, link, run, ok!
Five, note:
1, include the FFmpeg header file in the C + + source file when you need to add:
#ifdef __cplusplus
extern "C" {
#endif
... includes
#ifdef __cplusplus
}
#endif,
2,ffmpeg use is C99, but pit dad Microsoft until vs2012 seems to be C89, so do not rule out some of the files in the use of macros, functions will compile errors.
Common error: (Here is the cheat search traffic, strictly follow the steps of this blog post the children's shoes should not appear the following error)
1, configure appears "C99wrap CL is unable to create an executable file." and finally found in Config.log "Command line error d8021:invalid n Umeric argument ", you may be using the following version of VS2010. The official does not test this version, so it is best to use the new version of VS.
2, configure appears "C99wrap CL is unable to create an executable file." And finally found "config.log option-o" in Link:invalid because MSYS/1 0/bin/link.exe and vs link.exe conflict, will msys/1.0/link.exe temporarily change the name, such as Link_gnu.exe, compile and then change back.
Six, reference:
1,http://ffmpeg.org/platform.html#microsoft-visual-c_002b_002b-or-intel-c_002b_002b-compiler-for-windows
2,http://stackoverflow.com/questions/17218902/connect-ffmpeg-to-visual-studio-2008
3,https://github.com/xylcbd/ffmpeg_study
4,https://trac.ffmpeg.org/ticket/2610
Seven, PostScript supplement:
I'm sorry to tell you, FFmpeg source code is still a pit, flooded with code similar to the following:
if (Config_h264_vdpau_decoder && h->avctx->codec->capabilities & Codec_cap_hwaccel_vdpau) ff_ Vdpau_h264_picture_start (h);
Here, Config_h264_vdpau_decoder is a macro, in configure when the macro is turned off, then the Ff_vdpau_h264_picture_start function should never be executed, and then this paragraph will be optimized by the compiler. However, if you want to debug into the FFmpeg code, you should not turn on the compiler's optimization option (set:--disable-optimizations), which will allow the compiler to add an external ff_vdpau_h264_ to this obj Picture_start symbol, but in fact because of the Configure setting, an external CPP containing this symbol is not compiled, link when the linker tries to find this symbol, not found, then produce link error.
Turn on the optimization option while enable debug (--disable-optimizations--enable-debug=3). Can be debug, but may be very uncomfortable, some functions do not go in, some functions will jump to jump (single-step Debug).
Everybody, think twice.

Compiled with vs2010 under Windows FFmpeg

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.