编译ffmpeg

Guide : How to compile ffmpeg under Windows7 and VS2012

Postby sdancer75 » Mon Jul 29, 2013 4:51 pm

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"

a)Download FFMpeg distribution and extract it ie C:\ffmpeg\ (http://www.ffmpeg.org/releases/)
b)Download c99-to-c89 compiler and extract it at C:\ffmpeg\ (c99-to-c89-1.0.1.zip fromhttp://download.videolan.org/pub/contri ... 0.1/win32/)
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/)
d)Download msinttypes and extract it a C:\ffmpeg\msinttypes\ (https://msinttypes.googlecode.com/files ... es-r26.zip)


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) 

Rename mingw link.exe to avoid conflict with MS link.exe with "mv /bin/link.exe /bin/mingw_link.exe". Now running link.exe should point at MS link.
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 are ready. Just include your *.lib libraries in the linker input and Additional Dependecies option, and add your project includes, to the msinttypes (inttypes.h & stdint.h) you downloaded from the 1st step.
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

Postby Fendayen » Thu Aug 15, 2013 5:04 am

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.
Thank you in advance for your assistance.
Fendayen
 
Posts: 1
Joined: Thu Aug 15, 2013 4:53 am

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

Postby cybersinh » Fri Aug 16, 2013 10:20 pm

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

Postby sdancer75 » Sat Aug 17, 2013 7:29 am

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.
Thank you in advance for your assistance.


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

Postby JAYANTHI » Thu Nov 07, 2013 11:44 am

I have downloaded FFMPEG source code(c code) by the following link

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.

Referred Links:

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

Postby sdancer75 » Mon Nov 11, 2013 8:06 am

.....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

Postby JAYANTHI » Mon Nov 11, 2013 11:13 am

ok.. How to mention as MSVC c++ format at configuration parameter list.Please help me
JAYANTHI
 
Posts: 4
Joined: Thu Nov 07, 2013 9:29 am

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

Postby sdancer75 » Mon Nov 11, 2013 4:36 pm

JAYANTHI wrote:ok.. How to mention as MSVC c++ format at configuration parameter list.Please help me


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

Postby JAYANTHI » Tue Nov 12, 2013 4:44 am

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

Postby sdancer75 » Wed Nov 13, 2013 8:31 am

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
 
 
第一步安装完mingw的时候要记得设置环境变量,而且要设置在用户变量中,设置在系统变量中无法识别。。。
控制面板\系统和安全\系统—》高级系统设置-》环境变量-》在用户变量中添加PATH变量值为C:\MinGW\bin;C:\MinGW\msys\1.0\bin;
posted @ 2013-12-05 08:31  恒月美剑  阅读(4158)  评论(0编辑  收藏  举报