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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章