官方文档ffmpeg on window编译
2015-01-11 22:18
429 查看
本人按照http://ingar.satgnu.net/devenv/mingw32/base.html 的编译说明,成功编译出了ffmpeg的动态、静态库并在实际项目中使用
The base system consist of the GCC compiler, the MinGW-w64 runtime, and MSYS utilities.
The compiler abd the runtime are provided by packages from the MinGW-builds project. MSYS provides a UNIX-like shell environment.
Content
Installing the MinGW Installation Manager
Installing MSYS packages
Creating a desktop shortcut
Installing MinGW-w64
Post-installation configuration
Configuring vim
Installing additional packages in /opt
Building packages
Installing the MinGW Installation Manager
We begin by installing the MinGW Installation Manager. This program will allows us to install MinGW and MSYS packages. The MSYS packages provide the shell and the necessary command line tools, but we will not use the Installation Manager to install the MinGW compiler suite.
Download the MingGW Installation Manager setup:
mingw-get-setup.exe
Run the installer. Click the Install button to accept the license and continue.
Specify the installation directory, the default
Wait until the installation has finished and click the Continue button.
Installing MSYS packages
We use the MinGW Installation Manager to install MSYS packages:
Select Basic Setup on the left side of the screen. Mark the following packages to install:
Make sure no other packages are marked.
Open the Installation menu and click Apply Changes.
Click the Apply button.
Patiently wait for the installation to complete.
Click the Close button upon completion.
Install a number of additional packages, select All Packages on the left of the screen and mark the following packages for installation:
Note: in my installation, each package appeared multiple times. Select the top one.
Install the packages with the same procedure: open the Installation menu and click Apply Changes, click the Apply button, press the Close button upon completion.
Creating a desktop shortcut
Next, we create a new shortcut to launch the MSYS shell. CLick on the desktop with the right mouse button, select New -> Shortcut.
Set the location to
Right-click on the new shortcut and open its properties. Edit it so it looks like this:
Target:
Start in:
Press the OK button.
Launch the MSYS Shell by double-clicking the shortcut.
You can paste clipboard text to the RXVT terminal with the
Installing MinGW-w64
MinGW is a port of the GCC compiler to the win32 platform. MinGW-W64 adds 64-bit support and an improved windows runtime.
Before installing the compiler, a little bit of cleanup has to be done: the MinGW Installation Manager has put a number of packages into
Download the i686 package:
Sourceforge: i686-4.8.2-release-win32-sjlj-rt_v3-rev1.7z
Local mirror: i686-4.8.2-release-win32-sjlj-rt_v3-rev1.7z
If you want to build 64-bit applications, you'll also need the x86_64 package:
Sourceforge: x86_64-4.8.2-release-win32-seh-rt_v3-rev1.7z
Local mirror: x86_64-4.8.2-release-win32-seh-rt_v3-rev1.7z
Unzip the compiler packages into the
These packages support the win32 threading model and do not support C11 threading. Building GTK fails using the POSIX threading packages.
References:
http://mingw-w64.sourceforge.net/download.php
Post-installation configuration
MSYS emulates a UNIX file system hierarchy. By default, the MSYS directory
Mount the installation directory of the custom compiler package in a convenient location:
We will add a number of extra directories to
Additionally, we create a 64-bit variant for each of the 32-bit directories. Note that the /sources directory is the same for both environments, this prevents having to download source packages twice.
Create the necessary directories:
Mount the directories, this will automaticly add them to
Create necessary subdirectories in
Create /local32/etc/profile.local:
Create /local64/etc/profile.local:
Make sure it is executed on login:
Apply the new settings:
Note that the default environment is 32-bit. You can switch to the 64-bit environment with the following command:
Configuring vim
(Skip this section if you don't want to use the VIM editor)
Create a configuration file for VIM:
Set vim as default editor in the 32-bit environment:
In the 64-bit environment:
Installing additional packages in /opt
We install a few third-party tools in
Download and install the 7zip command line package:
Download and install the Portable Git package from msysgit:
Download and install the win32 subversion client using the following commands:
Download and install the win32 cmake client using the following commands:
Building packages
The following sections of this guide describe how to build various local packages. If you do not want to build them yourself, you can download my build:
32-bit local packages with GTK+msys-2013-12-14-local32-gtk.7z64-bit local packages with GTK+msys-2013-12-14-local64-gtk.7z
These packages should be extracted into the main installation directory
Remember you can always switch between environments by reading the apporiate profile:
To switch to the 32-bit build environment:
To switch to the 64-bit build environment:
The base system consist of the GCC compiler, the MinGW-w64 runtime, and MSYS utilities.
The compiler abd the runtime are provided by packages from the MinGW-builds project. MSYS provides a UNIX-like shell environment.
Content
Installing the MinGW Installation Manager
Installing MSYS packages
Creating a desktop shortcut
Installing MinGW-w64
Post-installation configuration
Configuring vim
Installing additional packages in /opt
Building packages
Installing the MinGW Installation Manager
We begin by installing the MinGW Installation Manager. This program will allows us to install MinGW and MSYS packages. The MSYS packages provide the shell and the necessary command line tools, but we will not use the Installation Manager to install the MinGW compiler suite.
Download the MingGW Installation Manager setup:
mingw-get-setup.exe
Run the installer. Click the Install button to accept the license and continue.
Specify the installation directory, the default
C:\MinGWis usually approriate. Review the other options and click the Continue button to begin the installation.
Wait until the installation has finished and click the Continue button.
Installing MSYS packages
We use the MinGW Installation Manager to install MSYS packages:
Select Basic Setup on the left side of the screen. Mark the following packages to install:
mingw-developer-toolkit
msys-base
Make sure no other packages are marked.
Open the Installation menu and click Apply Changes.
Click the Apply button.
Patiently wait for the installation to complete.
Click the Close button upon completion.
Install a number of additional packages, select All Packages on the left of the screen and mark the following packages for installation:
msys-rxvt
msys-unzip
msys-wget
msys-zip
Note: in my installation, each package appeared multiple times. Select the top one.
Install the packages with the same procedure: open the Installation menu and click Apply Changes, click the Apply button, press the Close button upon completion.
Creating a desktop shortcut
Next, we create a new shortcut to launch the MSYS shell. CLick on the desktop with the right mouse button, select New -> Shortcut.
Set the location to
C:\MinGW\msys\1.0\msys.bat, and call it MSYS Shell.
Right-click on the new shortcut and open its properties. Edit it so it looks like this:
Target:
C:\MinGW\msys\1.0\msys.bat --rxvt
Start in:
C:\MinGW\msys\1.0\bin
Press the OK button.
Launch the MSYS Shell by double-clicking the shortcut.
You can paste clipboard text to the RXVT terminal with the
shift+insertkey combination, hence can copy the commands from this guide and paste them into the terminal window. If you use the mouse to select text in the RXVT window, it will be automatically copied to the clipboard as well.
Installing MinGW-w64
MinGW is a port of the GCC compiler to the win32 platform. MinGW-W64 adds 64-bit support and an improved windows runtime.
Before installing the compiler, a little bit of cleanup has to be done: the MinGW Installation Manager has put a number of packages into
C:\MinGW\mingw32, rename it to
C:\MinGW\mingw.dist.
mv /c/MinGW/mingw32 /c/MinGW/mingw.dist
Download the i686 package:
Sourceforge: i686-4.8.2-release-win32-sjlj-rt_v3-rev1.7z
Local mirror: i686-4.8.2-release-win32-sjlj-rt_v3-rev1.7z
If you want to build 64-bit applications, you'll also need the x86_64 package:
Sourceforge: x86_64-4.8.2-release-win32-seh-rt_v3-rev1.7z
Local mirror: x86_64-4.8.2-release-win32-seh-rt_v3-rev1.7z
Unzip the compiler packages into the
C:\MinGWdirectory, you can use the 7-zip utility, or any archiver that understands the 7z format. You should and up with two new subdirectories:
C:\MinGW\mingw32and
C:\MinGW\mingw64.
These packages support the win32 threading model and do not support C11 threading. Building GTK fails using the POSIX threading packages.
References:
http://mingw-w64.sourceforge.net/download.php
Post-installation configuration
MSYS emulates a UNIX file system hierarchy. By default, the MSYS directory
C:\MinGW\msys\1.0will be mounted as root directory
/and as
/usr. Traditional windows drives like
D:and
E:can be accessed as
/dor
/e. Use the
mountcommand to get an overview:
$ mount C:\Users\Ingar\AppData\Local\Temp on /tmp type user (binmode,noumount) C:\MinGW\msys\1.0 on /usr type user (binmode,noumount) C:\MinGW\msys\1.0 on / type user (binmode,noumount) c: on /c type user (binmode,noumount) d: on /d type user (binmode,noumount)
Mount the installation directory of the custom compiler package in a convenient location:
mount 'C:\MinGW\mingw32\' /mingw32 mount 'C:\MinGW\mingw64\' /mingw64
We will add a number of extra directories to
/etc/fstab, to be mounted whenever a new shell is started:
/opt, where we will install a few extra packages,
/sources, where downloads will be saved,
/build32where we will download the sourcode and compile packages, and
/local32, where we will install our own compiled packages. These directories can be anywhere, but to keep the setup simple and consistent we will create
C:\MinGW\opt,
C:\MinGW\build32and
C:\MinGW\local32and mount them as
/opt,
/build32and
/local32.
Additionally, we create a 64-bit variant for each of the 32-bit directories. Note that the /sources directory is the same for both environments, this prevents having to download source packages twice.
Create the necessary directories:
mkdir /c/mingw/{opt,build32,local32,build64,local64,sources}
Mount the directories, this will automaticly add them to
/etc/fstab:
umount /mingw mount 'C:\MinGW' /mingw mount 'C:\MinGW\opt\' /opt mount 'C:\MinGW\local32\' /local32 mount 'C:\MinGW\build32\' /build32 mount 'C:\MinGW\local64\' /local64 mount 'C:\MinGW\build64\' /build64 mount 'C:\MinGW\sources\' /sources
Create necessary subdirectories in
/local32,
/local64and
/opt:
mkdir /opt/bin /local{32,64}/{bin,etc,include,lib,share} mkdir /local{32,64}/lib/pkgconfig
Create /local32/etc/profile.local:
cat > /local32/etc/profile.local << "EOF" # # /local32/etc/profile.local # alias dir='ls -la --color=auto' alias ls='ls --color=auto' PKG_CONFIG_PATH="/local32/lib/pkgconfig" CPPFLAGS="-I/local32/include" CFLAGS="-I/local32/include -mms-bitfields -mthreads -mtune=pentium3" CXXFLAGS="-I/local32/include -mms-bitfields -mthreads -mtune=pentium3" LDFLAGS="-L/local32/lib -mthreads" export PKG_CONFIG_PATH CPPFLAGS CFLAGS CXXFLAGS LDFLAGS PATH=".:/local32/bin:/mingw32/bin:/mingw/bin:/bin:/opt/bin" PS1='\[\033[32m\]\u@\h \[\033[33m\w\033[0m\]$ ' export PATH PS1 # directory where sources will be downloaded LOCALSOURCEDIR=/sources # package build directory LOCALBUILDDIR=/build32 # package installation prefix LOCALDESTDIR=/local32 export LOCALBUILDDIR LOCALDESTDIR EOF
Create /local64/etc/profile.local:
cat > /local64/etc/profile.local << "EOF" # # /local64/etc/profile.local # alias dir='ls -la --color=auto' alias ls='ls --color=auto' PKG_CONFIG_PATH="/local64/lib/pkgconfig" CPPFLAGS="-I/local64/include" CFLAGS="-I/local64/include -mms-bitfields -mthreads" CXXFLAGS="-I/local64/include -mms-bitfields -mthreads" LDFLAGS="-L/local64/lib" export PKG_CONFIG_PATH CPPFLAGS CFLAGS CXXFLAGS LDFLAGS PATH=".:/local64/bin:/mingw64/bin:/mingw/bin:/bin:/opt/bin" PS1='\[\033[32m\]\u@\h \[\033[33m\w\033[0m\]$ ' export PATH PS1 # directory where sources will be downloaded LOCALSOURCEDIR=/sources # package build directory LOCALBUILDDIR=/build64 # package installation prefix LOCALDESTDIR=/local64 export LOCALBUILDDIR LOCALDESTDIR EOF
Make sure it is executed on login:
cat >> /etc/profile << "EOF" if [ -f /local32/etc/profile.local ]; then source /local32/etc/profile.local fi EOF
Apply the new settings:
source /local32/etc/profile.local
Note that the default environment is 32-bit. You can switch to the 64-bit environment with the following command:
source /local64/etc/profile.local
Configuring vim
(Skip this section if you don't want to use the VIM editor)
Create a configuration file for VIM:
cat > ~/.vimrc << "EOF" " Configuration file for VIM set nocompatible set bs=2 " allow backspacing over everything in insert mode set ai " set autoindenting on " set backup " keep a backup file set nobackup " do not keep a backup file set history=256 " keep 256 lines of command line history set ruler " show the cursor position all the time set tabstop=8 " tab at 4 characters set shiftwidth=8 " 4 characters indentation set nowrap " do not wrap long lines set visualbell " no bell set background=light " msys rxvt has a light background "set background=dark " mingw shell uses a black background syntax on " syntax highlighting on EOF
Set vim as default editor in the 32-bit environment:
cat >> /local32/etc/profile.local << "EOF" EDITOR=vim export EDITOR EOF
In the 64-bit environment:
cat >> /local64/etc/profile.local << "EOF" EDITOR=vim export EDITOR EOF
Installing additional packages in /opt
We install a few third-party tools in
/optto prevent them from interfering with the default packages.
Download and install the 7zip command line package:
cd ${LOCALSOURCEDIR} && \ wget -c "http://downloads.sourceforge.net/sevenzip/7za920.zip" && \ cd /opt/bin && \ unzip ${LOCALSOURCEDIR}/7za920.zip && \ mkdir -p ../doc/7za920 && \ mv license.txt readme.txt 7-zip.chm ../doc/7za920
Download and install the Portable Git package from msysgit:
cd ${LOCALSOURCEDIR} && \ wget -c "http://msysgit.googlecode.com/files/PortableGit-1.8.4-preview20130916.7z" && \ cd /opt && \ 7za x ${LOCALSOURCEDIR}/PortableGit-1.8.4-preview20130916.7z && \ rm git-bash.bat git-cmd.bat 'Git Bash.vbs' && \ mv ReleaseNotes.rtf README.portable doc/git
Download and install the win32 subversion client using the following commands:
cd ${LOCALSOURCEDIR} && \ wget -c "http://downloads.sourceforge.net/project/win32svn/1.8.5/apache22/svn-win32-1.8.5.zip" && \ cd ${LOCALBUILDDIR} && \ unzip ${LOCALSOURCEDIR}/svn-win32-1.8.5.zip && \ cp -va svn-win32-1.8.5/* /opt && \ mkdir -p /opt/doc/svn-win32-1.8.5 && \ mv /opt/README.txt /opt/doc/svn-win32-1.8.5
Download and install the win32 cmake client using the following commands:
cd ${LOCALSOURCEDIR} && \ wget -c "http://www.cmake.org/files/v2.8/cmake-2.8.12.1-win32-x86.zip" && \ cd ${LOCALBUILDDIR} && \ unzip ${LOCALSOURCEDIR}/cmake-2.8.12.1-win32-x86.zip && \ cp -va cmake-2.8.12.1-win32-x86/* /opt
Building packages
The following sections of this guide describe how to build various local packages. If you do not want to build them yourself, you can download my build:
32-bit local packages with GTK+msys-2013-12-14-local32-gtk.7z64-bit local packages with GTK+msys-2013-12-14-local64-gtk.7z
These packages should be extracted into the main installation directory
C:\MinGW, you should end up with
C:\MinGW\mingw32and/or
C:\MinGW\mingw64.
Remember you can always switch between environments by reading the apporiate profile:
To switch to the 32-bit build environment:
source /local32/etc/profile.local
To switch to the 64-bit build environment:
source /local64/etc/profile.local
相关文章推荐
- android官方文档:ubuntu10.04下编译android源码Building the System
- Android编译系统(三):官方文档Android Build System
- Ubuntu安装ffmpeg带h264,aac,MP3等功能的版本的官方文档
- spark官方文档之——Running Spark on YARN YARN上运行SPARK
- window下ffmpeg的编译
- 在window平台下编译ffmpeg
- Window 平台 FFmpeg Android .so文件编译
- openWRT自学---对官方的开发指导文档的解读和理解 记录1:编译一个package
- ffmpeg ubuntu 官方编译
- 谷歌安卓官方文档之编译内核
- Window下编译Ffmpeg到ActiveX打包(转)
- #android-ndk-r8d 使用 独立 编译 工具链 官方文档 中英文 对照
- Android编译系统(三):官方文档Android Build System
- openWRT自学---对官方的开发指导文档的解读和理解 记录2:如何控制内核模块的编译
- [cpp 编译]Autotools笔记 翻译自autotools官方文档
- webrtc 编译运行官方文档http://www.webrtc.org/reference/getting-started
- window下编译 ffmpeg
- Ubuntu11.04 32位 下用android-ndk-r8b 编译ffmpeg-1.1 (之前摸索了两天(大部分文章都太乱太杂),终于参考这边文档,编译完成了....)
- Linux编译FFmpeg支持x265(HEVC) 【failed on redhat 6.5】(updated)
- ffmpeg 官方文档 上篇 (译)