# 编译ffmpeg

### Guide : How to compile ffmpeg under Windows7 and VS2012

How to successfully compile ffmpeg under windows.
My latop is Windows 7 64Bit and VS2012 but I am compiling in 32bit mode.

Step 1)
Download mingw and install it (choose C, C++, MSYS Basic System, MinGW Developer Toolkit.)
Run minGW shell and type the following commands
"mingw-get install zlib"
"mingw-get install libz-dev"

c)Download yasm-1.2.0-win32 and extract it at C:\yasm\ (or win64 for 64bit builds fromhttp://www.tortall.net/projects/yasm/releases/)

Step 2)

Open up visual studio 2012 developer console ( under Start>All Programs> VS12> VS Tools> Developer command prompt for VS12 ) and Navigate to c:\MinGW\msys\1.0>

Step 3)

Run msys.bat from here.

Step 4)

Change your current home directory to ffmpeg ie "cd C:/ffmpeg"

Step 5)

Double check with the command "which link" it should respond something like "/c/Program Files (x86)/Microsoft Visual Studio 11.0/VC/Bin/link.exe"

Step 6)

Extend default path with the command "export PATH=$PATH:C:/ffmpeg" Check the result, with the command "echo$PATH". It should report all Visual Studio's paths, plus c:\ffmpeg

Step 7)
type the commands below. (a) and (b) take some time to complete (about 5-10 minutes)
a) "./configure --prefix=ffmpeg/ --enable-shared --extra-cflags=-I/c/MinGW/include --yasmexe='C:/yasm/yasm-1.2.0-win32.exe' --enable-gpl --cpu=i686"
b) "make"
c) "make install"

Step 8) Now under "C:\ffmpeg\ffmpeg\lib" you should see some *.def and *.a files. Its time to convert *.a to standard MS *.lib files.
Change directory using the command "cd .\ffmpeg\lib"

Take a file list with "ls -l" command.

For every *.a file you see, use the following command
"lib /machine:i386 /def:<filename>.def /out:<filename>.lib" ie
"lib /machine:i386 /def:avcodec-54.def /out:avcodec-54.lib"

Step 8)

You may also set References to No (/OPT:NOREF) under the linker optimization settings, project properties>linker>optimization>References to No (/OPT:NOREF)
sdancer75

Posts: 10
Joined: Fri Jul 26, 2013 2:35 pm

### Re: Guide : How to compile ffmpeg under Windows7 and VS2012

First, let me thank you for posting this incredibly detailed guide.

Unfortunately, I am running into a complication at Step 7) a), which requests me to use the following command:
"./configure --prefix=ffmpeg/ --enable-shared --extra-cflags=-I/c/MinGW/include --yasmexe='C:/yasm/yasm-1.2.0-win32.exe' --enable-gpl --cpu=i686"

When I use the command, I receive the following feedback:
"sh: ./configure: No such file or directory"

When using the command exactly as you provided did not work, I attempted changing what I perceived to be the directory ('C:/yasm/yasm-1.2.0-win32.exe') multiple times. I am using the exact commands which you provide and am also placing everything in the example directories you provide. My OS is also Windows 7. The only difference I see is that I am using VS2010 instead of VS2012, but I doubted that would cause a directory problem -- or would it?

I am very new at using MinGW, and am not knowledgeable about it, so I expect this to just be a problem of user error.
Fendayen

Posts: 1
Joined: Thu Aug 15, 2013 4:53 am

### Re: Guide : How to compile ffmpeg under Windows7 and VS2012

Hi,

You do not seem to use the MSVC compiler, but gcc, without "--toolchain=msvc" option for "./configure".

So, feel free to update your guide. Thanks.
cybersinh

Posts: 1
Joined: Fri Aug 16, 2013 10:12 pm

### Re: Guide : How to compile ffmpeg under Windows7 and VS2012

Fendayen wrote:First, let me thank you for posting this incredibly detailed guide.

Unfortunately, I am running into a complication at Step 7) a), which requests me to use the following command:
"./configure --prefix=ffmpeg/ --enable-shared --extra-cflags=-I/c/MinGW/include --yasmexe='C:/yasm/yasm-1.2.0-win32.exe' --enable-gpl --cpu=i686"

When I use the command, I receive the following feedback:
"sh: ./configure: No such file or directory"

When using the command exactly as you provided did not work, I attempted changing what I perceived to be the directory ('C:/yasm/yasm-1.2.0-win32.exe') multiple times. I am using the exact commands which you provide and am also placing everything in the example directories you provide. My OS is also Windows 7. The only difference I see is that I am using VS2010 instead of VS2012, but I doubted that would cause a directory problem -- or would it?

I am very new at using MinGW, and am not knowledgeable about it, so I expect this to just be a problem of user error.

Hi,

It seems you are not under the ffmpeg directory, that's why you get such an error.

Try to get in inside the ffmpeg directory. Getting a file list with "ls -l" you will see a file called "configure". It is just a script file, that you can also open it with the notepad.

After you verify that you can see the configuration file then you will able to run the script.

PS: Also remember to get in command line (before you call the mingw) with the Visual Studio's Command Prompt, to have access to all Visual Studio tools.
sdancer75

Posts: 10
Joined: Fri Jul 26, 2013 2:35 pm

### Re: Guide : How to compile ffmpeg under Windows7 and VS2012

http://ffmpeg.zeranoe.com/builds/

After that,I have completed the configuration part then i was generated and linked the library files [avcodec-54.lib,avdevice-54.lib,avfilter-3.lib,avformat-54.lib,avutil-52.lib,swresample-0.lib,swscale-2.lib ]on Microsoft Visual Studio C++ by creating a new project by including all .c and header files.

http://www.ffmpeg.org/platform.html#Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows

http://ramu492.blogspot.in/2013/06/port ... 7-and.html

When I was compiling on Visual studio 2010... I am getting more than 300 errors under all the fileslibavcodec,libavdevice,libavfilter,libavformat,libavresample,libavutil,libpostproc,libswresample,libswscale like

ASM ERRORS:

error C2400: inline assembler syntax error in 'opcode'; found 'data type'
error C2065: '__asm__' : undeclared identifier
error C2143: syntax error : missing ';' before 'volatile'

SYNTAX ERRORS:

error C2143: syntax error : missing '}' before '.'
error C2143: syntax error : missing ';' before '.'
error C2059: syntax error : '.'
error C2143: syntax error : missing ';' before '}'
error C2059: syntax error : '}'
error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)
error C2059: syntax error : ','
error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)

Please anyone let me know how to compile a ffmpeg c code on vs2010 successfully.
JAYANTHI

Posts: 4
Joined: Thu Nov 07, 2013 9:29 am

### Re: Guide : How to compile ffmpeg under Windows7 and VS2012

.....maybe you did not mentioned that you are intended to use msvc c++ format and not gcc at the configuration parameters list.

Did you also checked that you are using the MSVC's lib.exe and not the default one to create your libs ?

Regards,
sdancer75

Posts: 10
Joined: Fri Jul 26, 2013 2:35 pm

### Re: Guide : How to compile ffmpeg under Windows7 and VS2012

JAYANTHI

Posts: 4
Joined: Thu Nov 07, 2013 9:29 am

### Re: Guide : How to compile ffmpeg under Windows7 and VS2012

Did you followed my instructions at the 1st post ? If not, please try it.

I am not sitting in my development computer right now, but if you have dificulties I can give you my exact configure parameters tommorow.

Anyway, you have to use the following parameter at the configuration build.

--toolchain=msvc

ie

1)./configure --prefix=ffmpeg/ --enable-shared --extra-cflags=-I/c/MinGW/include --yasmexe='C:/yasm/yasm-1.2.0-win32.exe' --enable-gpl --cpu=i686 --enable-shared --toolchain=msvc
2) make
3) make install

In my case I didn't use it and it worked just fine without this....

At the end you will have a list of *.a and *.def files. At this point, you have to create your *.dll and *.lib files using the lib.exe that bundled with your Visual Studio.

The syntax is

lib.exe /machine:i386 /def:<filename>.def /out:<filename>.lib

ie

lib.exe /machine:i386 /def:avcodec-54.def /out:avcodec-54.lib

Dont forget to rename before the standard minigw's link.exe to avoid conflicts with the MSVC' link.exe. Its also important to get in the command prompt from the Visual Studio command prompt tool, otherwise you will not have access to all other visual studio tools.

PS1:You can check also the project lavfilter at https://code.google.com/p/lavfilters/source/browse/ and build with the "build_ffmpeg_msvc.sh". Project home at http://1f0.de/lav-splitter/
PS2: Check also the instructions at https://trac.ffmpeg.org/wiki/CompilationGuide
PS3: if I still have a problem maybe I can create a video tutorial.

Regards,
sdancer75

Posts: 10
Joined: Fri Jul 26, 2013 2:35 pm

### Re: Guide : How to compile ffmpeg under Windows7 and VS2012

Hi,

"./configure --prefix=ffmpeg/ --enable-shared --extra-cflags=-I/c/MinGW/include --yasmexe='C:/yasm/yasm-1.2.0-win32.exe' --enable-gpl --cpu=i686 --enable-shared --toolchain=msvc"

In my case , it is not working showing error like,

c99wrap cl is unable to create an executable file.
If c99wrap cl is a cross compiler, use --enable-cross-compile option.
Only do this if u know what cross compiling means.
C compiler test failed.

can you help me to overcome this issue
JAYANTHI

Posts: 4
Joined: Thu Nov 07, 2013 9:29 am

### Re: Guide : How to compile ffmpeg under Windows7 and VS2012

I will upload a video on youtube... I will let you know as soon as I upload it !
sdancer75

Posts: 10
Joined: Fri Jul 26, 2013 2:35 pm

posted @ 2013-12-05 08:31 恒月美剑 阅读(...) 评论(...) 编辑 收藏