编译MPC-HC

主要环境:(参考附件)

1.windows sdk v6.1,官方文档里的新版SDK没试过。

2.VS2008+sp1+atl安全补丁(一定要先装WINDOWS sdk再装vs2008,否则二者冲突,编译出错报_Swap_adl,这是VS开发组的BUGhttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/4bc93a16-4ad5-496c-954c-45efbe4b180b)

3.directx 2010 Feb版,安装好后配置VS里的include和lib

 

4. Alexins's Cross-Mingw  base 和Alexins's Cross-Mingw.GCC Core,参见官方文档设置,注意fstab文件

5.建立环境变量

 

6. 使用TortoiseSVN 下载 mpc-hc源码:source-forge里mpc-hc  tags 文件夹下release_v1_3_1249_0,内有一个旧的编译说明

 

7.编译文档里没有提到要给VS添加C:/mingw_msys/msys.450x64v2/bin和C:/mingw_msys/msys.450x64v2/mingw/bin

我没添加时会报找不到yasm.exe和gcc的错误。添加后OK

主要步骤与问题

1.生成version.h

打开cmd,输入 "C:/Program Files/TortoiseSVN/bin/SubWCRev.exe"   c:/mpc/   c:/mpc/include/SubWCRev.conf   c:/mpc/include/Version.h

换成自己的目录即可

 

2.直接copy  C:/mingw_msys/msys.450x64v2/mingw/lib/gcc/i686-pc-mingw32/4.5.0/ibgcc.a到源代码目录下的lib文件夹

 

3.修改src/subtitles/CCDecoder.cpp 的static WCHAR charmap[0x60]   数组‘?  换为  ’?’.也有说用ultraedit保存为UTF8格式的,我没试过。

4.设置MPCVideoDec 的库环境

5.开始编译。

 

 

注意:

选择debug or release是对生成的程序有区别的.

release版即最后发布的版本,正常

但debug版效率很低,播放高清视频时会卡,揪其原因是因为编译过程中debug版调用libavcodec工程,而release版调用libavcodec_gcc.效率是不同的.

 

 

 

参考资料

1.http://hi.baidu.com/cobala/blog/item/f61038ea04b585d4d439c94d.html/cmtid/338af608a04ce23ce824884c

2.http://blog.csdn.net/iihero/archive/2009/05/19/4202300.aspx

3.http://beatricesmth.blog41.fc2.com/?tag=MPC-HC

附件:官方编译文档立此存照

 

How-to compile MPC-HC

Part A: Preparing the Visual Studio environment.

1. Install Visual C++ 2008 (part of the Visual Studio package downloadable here:

URL: http://msdn.microsoft.com/en-us/evalcenter/bb633753.aspx). 
Note: Express edition won't work (it's missing MFC, which MPC-HC uses).

2. Install Service Pack 1 (SP1) for Visual Studio 2008 and all the Visual Studio updates via Windows Update (>300MB).

URL: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=fbee1648-7106-44a7-9649-6d9f6d58056e

3. Install Visual Studio 2008 Service Pack 1 ATL Security Update (Come with Windows Update)

URL: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=294de390-3c94-49fb-a014-9a38580e64cb

4. Install DirectX SDK (February 2010).

URL: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=2c7da5fb-ffbb-4af6-8c66-651cbd28ca15

5. Open Visual Studio and go to Tools->Options->Projects and Solutions->VC++ Directories, and add the following:

a) To the end of "Include files", add: $(DXSDK_DIR)include
b) To the end of "Library files", add: $(DXSDK_DIR)lib/x86
c) Press OK to save.
Note: It's important to add the new paths at the END! 
Note2: Newer DXSDK versions should add the needed paths automatically upon installation so the above might not be needed.

6. Install Windows SDK v7.0 and use its configuration tool to make it the default SDK.

URL: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505

Note: This version has a known bug regarding registering itself as the default SDK (on specific systems):
See :http://blogs.msdn.com/windowssdk/archive/2009/08/21/windows-sdk-configuration-tool-may-report-an-error-when-os-display-format-is-not-english.aspx

Part B: Preparing the GCC environment.

1. Download and extract Alexins's Cross-Mingw.GCC Base to c:/mingw_msys/msys.450x64v2/

URL:  .7z">http://www.xvidvideo.ru/clsid/msys.450x64v2.7z

2. Download and extract Alexins's Cross-Mingw.GCC Core to c:/mingw_msys/msys.450x64v2/mingw/

URL: http://www.xvidvideo.ru/2009-10-22-10-49-14/cat_view/28-cross-mingwgcc-x86x64/160-cross-mingw-with-gcc-45-x86x64.html

* Optional, If you do not wish to use the cutting edge branch you can instead follow these steps:

  1. Delete everything in this folder: c:/mingw_msys/msys.450x64v2/mingw/
  2. Download and extract the stable version into c:/mingw_msys/msys.450x64v2/mingw/

URL: http://www.xvidvideo.ru/2009-10-22-10-49-14/doc_details/3567-cross-mingw-x86x64-201004292200-with-gcc-444-stable-pthreads-290-static.html

3. Edit the "fstab" file in c:/mingw_msys/msys.450x64v2/etc/ to specify your mingw path

Add this to it: c:/mingw_msys/msys.450x64v2/mingw /mingw (*note the tab-space between mingw and /mingw)

4. Make the following changes to Windows' environment variables (in System Properties->Advanced->Environment Variables):

Variable Value
MSYS c:/mingw_msys/msys.450x64v2/
MINGW32 c:/mingw_msys/msys.450x64v2/mingw/
MINGW64 c:/mingw_msys/msys.450x64v2/mingw/
YASM c:/mingw_msys/msys.450x64v2/bin/

*Note: Backslash at the end''

Part C: Downloading and compiling the MPC-HC source.

1. Use a subversion client to checkout mpc-hc's trunk to C:/mpc-hc

Repository URL: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk 

You may want to use TortoiseSVN (GUI) or Slik SVN (Commandline):

  1. TortoiseSVN http://tortoisesvn.net/downloads
  2. Slik SVN http://www.sliksvn.com/en/download

2. When using TortoiseSVN

a) Create an empty directory where you want to store the source files. e.g: C:/mpc-hc 
b) Right-click on that directory and choose "SVN checkout".
c) Put https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk in "URL of Repository" and press OK.
d) Wait for the source tree to be downloaded.

3. Open the solution file C:/mpc-hc/mpc-hc.sln

Change the solution's configuration to "Release Unicode" (in the toolbar).

4. Right click the MPCVideoDec project, and open up its Properties.

There, go to Configuration Properties->Librarian->General.

5. Change the "Additional Library Directories" to:

For mingw gcc 4.5.0 x86 ../../../../lib;$(MINGW32)/lib/gcc/i686-pc-mingw32/4.5.0;$(MINGW32)/i686-pc-mingw32/lib/
For mingw gcc 4.5.0 x64 ../../../../lib64;$(MINGW64)/lib/gcc/x86_64-w64-mingw32/4.5.0;$(MINGW64)/x86_64-w64-mingw32/lib/
For mingw gcc 4.4.2 x86 ../../../../lib;$(MINGW32)/lib/gcc/i686-pc-mingw32/4.4.2;$(MINGW32)/i686-pc-mingw32/lib/
For mingw gcc 4.4.2 x64 ../../../../lib64;$(MINGW64)/lib/gcc/x86_64-w64-mingw32/4.4.2;$(MINGW64)/x86_64-w64-mingw32/lib/

6. Press OK to save the changes and close the Properties window.

7. Press F7 to build the solution.

8. You now have mpc-hc.exe under C:/mpc-hc/src/apps/mplayerc/Release Unicode.

9. Open the solution file C:/mpc-hc/src/apps/mplayerc/mpciconlib.sln

10. Press F7 to build the solution.

11. You now have mpciconlib.dll under C:/mpc-hc/src/apps/mplayerc/Release Unicode.

12. Open the solution file C:/mpc-hc/src/apps/mplayerc/mpcresources.sln

In Visual Studio go to Build->Batch Build->Press Select All->Press Build

13. You now have mpcresources.XX.dll under C:/mpc-hc/src/apps/mplayerc/Release Unicode.

Part D: (optional) Building the installer.

Download Inno Setup Quick Start Pack Unicode v5.3.9 or newer.
Install everything and then go to C:/mpc-hc/distrib, open mpc-hc_setup.iss with Inno Setup or ISTool and compile it.

Part E: Building libavcodec with gcc for x64

When building libavcodec (project libavcodec_gcc)in 32 bit mode gcc is used and according to the makefile that is automatically invoked from the solution. Doing so for 64 bit, requires some additional steps (in accordance with this post by Spec-Chum):

  1. with msys enter the trunk/src/filters/transform/MPCVideoDec/ffmpeg_x64 folder

for example, one could run start a bash session by running:

 cmd /c d:/src/toolz/msys/bin/bash.exe -login

then, inside that console, change the directory by typing at the $ prompt:

 cd /d/src/C/mpchc/trunk/src/filters/transform/MPCVideoDec/ffmpeg_x64/

(notice that the first part will most probably differ for the exact paths)

  1. at this point you could run buildffmpeg.sh --updatemingw but since it also builds what it downloads (and some changes are necessary), better do this step by step:
  2. checkout the mingw files by running:
     $ ./buildffmpeg.sh --updatemingw
    
  3. modify delayimp.c (found after the previous step at trunk/src/filters/transform/MPCVideoDec/ffmpeg_x64/build/mingw/mingw-w64-crt/misc/delayimp.c) such as the line:
     #define __ImageBase __MINGW_LSYMBOL(_image_base__)
    

becomes:

 //#define __ImageBase __MINGW_LSYMBOL(_image_base__)

(comment it, else you will get an error when linking libavcodec with MSVC)

  1. run the buildffmpeg.sh script, only to compile:
     ./buildffmpeg.sh --compilemingw
    
  2. after the compilation is done, libgcc.a and libmingwex.a will be placed in trunk/lib64

Now libavcodec can be compiled from within the mpc-hc visual studio solution file, and it will be linked correctly with the other components.

 

Credits: Written by Avi Vahl/Alexins and every other person who contributed.

 

你可能感兴趣的:(编译MPC-HC)