Bandi küldte nekem az alábbi, általa hősi erőfeszítések árán összeszenvedett guide-ot, remélem hasznos lesz valakinek:
/ Bandi has sent me the following guide, which was created by him with heroic efforts. I hope it will be useful for someone.
I. Introduction
This document shall serve as a guide for the brave ones trying to compile MPlayer for Windows.
First of all you should know, that as the author of this guide, I am a human being too, which means, there could be errors all the time, however I tried to eliminate all of them. Errors will most likely occur, if any of the components mentioned below are updated. In that case, try to Google, try to fix them, and write much better guides than this one :-)
For I’m neither a master of porting software from Linux to Windows, there could be some seriously stupid things, I’ve done here. If there are, well… sorry for them.
Since I’m not a native english speaker, my english may be broken sometimes :-)
If you are up to compile MPlayer on Windows, you must have some general knowledge about computers and stuff, otherwise you won’t be doing so. Well you have to face the fact, it won’t be easy but it will be a real pain in the ass. If in any case this guide isn’t clear and detailed enough, use that knowledge of yours! It would take a long long time to explain everything detailed like hell…
So why MinGW? Well, I have tried several times, first in MinGW, but actually I have failed. After that I tried with Cygwin, but that wasn’t easier neither. After some search and reading done I reconsidered the whole MinGW stuff, and succeded. Now that is what we are trying to accomplish again.
First of all, I have to mention that this guide is mainly based on the one at the MPlayer page, which is a really great guide, but is a little outdated. So I’ve extended it with some fixes.
The program paths I provide are the default installation paths, for example c:\mingw
for MinGW. If you use custom paths, please substitute it with your own!
In this guide I will try to use static libraries all the time, to avoid the use of DLL files.
If I talk about some program and its installation here, I always mention the version I have used, if in any case the compilation of a newer version fails, you could always return to the version I used here, and that way everyting is supposed to work fine. Of course this doesn’t mean never to use newer versions, because newer versions should always be better. However you might consider the use of „stable” versions (if possible not alpha, beta etc.) to avoid possible errors.
II. MinGW, MSYS and MSYS DTK
First get the latest MinGW, and install it. (Links are provided in the title. MinGW should be the very first download!) While installing if not selected, select the g++ compiler too. In this document MinGW version 5.1.4 is used.
Now get MSYS and MSYS DTK. MSYS goes under the name MSYS Base System. Once clicked its link, check below to find version 1.0.10. By the time this guide was written 1.0.10 was the latest version which had Windows binaries. Install it, and continue with the postinstall, it should be űtty self explanatory.
MSYS DTK goes under the name MSYS Supplementary tools, install it too! Check at the bottom again! Version 1.0.1 was used here.
Before we proceed to the next step there is still some business that needs to be taken care of. The MinGW environment has some bugs which prevent you from seeking in large files (above 4GB or 6GB I’m not sure) with the MPlayer you build. Well, thats definitely not, what you want. In order to avoid this, get this patch of Gianluigi Tiesi.
In case the link may be down lets see the patch here too:
diff -Nur mingw-runtime-3.14.orig/include/io.h mingw-runtime-3.14/include/io.h --- mingw-runtime-3.14.orig/include/io.h 2007-12-27 15:21:39.000000000 +0100 +++ mingw-runtime-3.14/include/io.h 2008-03-29 02:02:40.343750000 +0100 @@ -333,6 +333,10 @@ #endif /* Not _NO_OLDNAMES */ +#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 +#define lseek _lseeki64 +#endif + #ifdef __cplusplus } #endif diff -Nur mingw-runtime-3.14.orig/include/sys/stat.h mingw-runtime-3.14/include/sys/stat.h --- mingw-runtime-3.14.orig/include/sys/stat.h 2007-12-27 15:21:40.000000000 +0100 +++ mingw-runtime-3.14/include/sys/stat.h 2008-03-29 02:02:40.343750000 +0100 @@ -187,6 +187,13 @@ #endif /* _WSTAT_DEFIND */ #endif /* __MSVCRT__ */ +#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 +#undef stat +#define stat _stati64 +#define fstat _fstati64 +#define wstat _wstati64 +#endif + #ifdef __cplusplus } #endif diff -Nur mingw-runtime-3.14.orig/include/sys/types.h mingw-runtime-3.14/include/sys/types.h --- mingw-runtime-3.14.orig/include/sys/types.h 2007-12-27 15:21:40.000000000 +0100 +++ mingw-runtime-3.14/include/sys/types.h 2008-03-29 02:02:40.359375000 +0100 @@ -35,7 +35,11 @@ #ifndef _OFF_T_ #define _OFF_T_ +#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 +typedef long long _off_t; +#else typedef long _off_t; +#endif #ifndef _NO_OLDNAMES typedef _off_t off_t;
Don’t be scared, its not as bad as it seems! In a nutshell: Patch is a UNIX utility that applies a script generated by the diff program to a set of files, allowing changes from one file to be automatically applied to another file.
You could apply the patch with any program which is able to use patches, if you would be using the right version of mingw-runtime. Bad for us, 5.1.4 comes with 3.15.1, so you have to use the patch manually, or fix it and use it automated. Since fixing is as much work as manual patching I recommend doing it manually.
Studying the anatomy of the patch you must have noticed that in the „diff” line there is the name and path of the file which needs to be modified. After that the line with the „@@” characters marks the line in wich the code must be modified. It may be a little smaller or a little bigger number depending on the version you use. The „+” marks below mean line must be added („-” would mean line must be removed). Okay, search the correct places (surrounding lines help) and add the lines to the header files. If done right, the evil bug is terminated!
You can also upgrade your w32api and bash right here, or do it later when compiling ffmpeg. The upgrade process is described in section IX. I’ve done it later since I didn’t know that it will be needed in the future ;-)
III. DirectX headers
Get the required DirectX headers here, and copy them into the c:\mingw\include folder!
IV. OGG, Vorbis and Theora
The guide on which this is based on mentions that newer MPlayer versions include sources, to play vorbis audio, but still, setting up some codecs won’t hurt :-) Go to http://downloads.xiph.org/releases/ and download the latest library archives (with extension .tar.gz) in the subdirectories ogg, vorbis and theora. In this document libogg-1.1.3, libvorbis-1.2.0, and libtheora-1.0 are used.
Now start the MSYS shell! The default library os yours should be c:\msys\1.0\home\usr
, where usr is your user name.
Extract the ogg archive there (use MSYS command line or your favourite 3rd party utility…) and cd in its folder.
Now its time o build libogg! How do we do that? On Unix-like systems there is a great stuff called GNU build system. First you have to run a configure script, then you can build and install your sources. Lets do that now!
Call configure with your mingw install dir as prefix:
./configure --prefix=c:/mingw --disable-shared
compile the sources:
make
and install them:
make install
afterwards go back to your msys home dir:
cd
Now install libvorbis in a similar way:
./configure --prefix=c:/mingw --disable-shared make make install
And then libtheora:
./configure --disable-encode --prefix=C:/mingw --disable-shared make make install
V. Compile freetype for OSD font rendering
First, freetype requires libiconv support, which you can get from http://ftp.gnu.org/gnu/libiconv/ The version used in this document is 1.13.
Download it and install the following way:
./configure --prefix=c:/mingw --disable-shared make make install
Now lets continue with freetype2! You can get it from its Sourceforge page. Version used in this document is 2.3.7. The reason for that is, that newer versions require newer GCC, and I didn’t want to mess with that. If you are brave you could try, there is a newer GCC avaliable from the MinGW SF.net page. Copying the contents of the archive to the right place should do the trick.
Before we proceed we must do some hacking in the good old stdlib.h
, otherwise freetype won’t compile.
So make the following changes in line 317 of the file C:\MinGW\include\stdlib.h
(change inline
to __inline__
):
__inline__ double __cdecl __MINGW_NOTHROW strtod (const char* __restrict__ __nptr, char** __restrict__ __endptr)
And now the ordinary install stuff:
./configure --prefix=c:/mingw --disable-shared make make install
VI. zlib, libregif, libpng, libjpeg
Sources are available from:
http://www.gzip.org/zlib/ Version 1.2.3 used.
http://armory.nicewarrior.org/projects/libregif/ Version 4.1.7 used.
http://sourceforge.net/project/showfiles.php?group_id=5624 Version 1.2.35 used.
http://www.ijg.org/ Version 6b used.
MOV compressed header support requires zlib, which MinGW does not provide by default, thats why it is needed to install. Install it the following way:
./configure --prefix=c:/mingw make make install
Then libpng:
./configure --prefix=c:/mingw --disable-shared make make install
After that jpegsrc:
./configure --prefix=/mingw/ --enable-static make cp .libs/libjpeg.a c:/mingw/lib/ cp jpeglib.h jconfig.h jmorecfg.h c:/mingw/include/
And finally libregif:
./configure --prefix=c:/mingw make make install
VII. lame, xvid and x264
First get the nasm sources from http://sourceforge.net/project/showfiles.php?group_id=6208 because it is the requirement of Xvid. Version used here is 2.05.01.
Install it:
./configure --prefix=c:/mingw make mkdir c:/mingw/man/man1 (In case the library doesn't exist, but most likely it will.) make install
Now get lame from http://sourceforge.net/project/showfiles.php?group_id=290&package_id=309.
In this document the latest version, 3.98.2 is used.
Install it this way:
./configure --prefix=c:/mingw --disable-shared --disable-decoder make make install
Obtain a copy of Xvid source from http://www.xvid.org/downloads.html. Version used here is 1.2.1.
The installation instructions are the following:
./configure --prefix=c:/mingw --disable-shared make make install mv c:/mingw/lib/xvidcore.a c:/mingw/lib/libxvidcore.a
Before we continue with x264 first we have to install yasm and pthreads. Although it is possible to compile x264 without yasm, x264 will warn you, and it is beyond my knowledge what will happen in that case.
Get yasm from http://www.tortall.net/projects/yasm/wiki/Download, the version used in this guide is 0.7.2.
Install it:
./configure --prefix=c:/mingw make make install
Now get pthreads from ftp://sourceware.org/pub/pthreads-win32/. Version used here is 2.8.0.
This is the point where I messed up a bit, but since I’ve tried to compile MPlayer several times with several hours spent, I was just lazy to start over again :-) You must have noticed that you cannot use ./configure
command in the pthreads directory. So you just have to use the make
command, which will scream for arguments.
I have installed it this way:
make clean GC
Because I was lazy, after building MPlayer I’ve noticed, that I cannot run mplayer.exe without the DLL pthreads creates. This particular DLL is named pthreadGC2.dll which can be found in the c:\mingw\bin directory and is created by the pthreads installation because no static build is commanded. After I have realized what I have done I tried to compile certain parts again, but couldn’t make it without this DLL. So i guess I have to live with that, because it is not the end of the world, or start over again :-) If you do it the way I did, you have to keep the pthreadGC2.dll next to mplayer.exe or in your system’s default folder for DLL files to be able to execute the program. If you don’t want any of this, build the source with static libraries: make clean GC-static. This should save your soul, but I haven’t tested it (however it should not raise any further errors).
Now finally we have arrived to x264. Grab a daily tarball with its source code from the Videolan x264 project page. I don’t mention any version here, just grab the latest source, and cross your fingers :-) Extract it and open the configure
file for editing. Change the first line to #! /bin/sh
, otherwise you won’t be able to run the script.
Now install it:
./configure --prefix=/mingw --enable-avis-input --enable-pthread make make install
VIII. Live rtsp streaming support
Get the latest sources from the live555 home page.
Compile it:
genMakefiles mingw make
Copy the live folder and its contents to c:\msys\1.0\lib so MPlayer will recognize it, because the switch to tell MPlayer what library to use for live555 rtsp support is somehow gone from the configuration options.
IX. Building ffmpeg
You could ask here, why is it needed to do this, since MPlayer already includes ffmpeg. Well you could give it a try, but there will be an error while compiling MPlayer, because something is not right in its ffmpeg source. At least it wasn’t right for me, at least it wasn’t right under MinGW, at least for 1.0rc3. Thats why is needed to compile a working ffmpeg first, so MPlayer can use it when building.
Get an SVN client, or use CVS in MSYS. I recommend you using an SVN client with some GUI, it will be easier that way. I used TortoiseSVN, you can get it from the TortoiseSVN page. Note, that it requires Subversion, which you can get on the Subversion page. Download and install them, its not that hard, and it is not the goal of this guide to explain how to install programs in Windows :-)
For building ffmpeg you will need at least w32api-3.13. If I’m right, MINGW version 5.1.4 has a built in version 3.12 of w32api. Well, that is the stuff, you need to upgrade. Get the newest w32api sources from SF.net. In this guide version 3.13 is used. Download both tarballs, and extract the „include
„, „lib
” folders and other files into your c:\mingw
folder. Overwrite if necessary.
After this tiny upgrade ;-) you will need a new bash for MSYS too, from which you will need at least version 3.1. According to this guide. You can get the compiled bash from the link I described above. That link points to a snapshot on SF.net, but you can get the version 3.1 bash from the MINGW project page too. I have used the snapshot archive. If you use the MINGW project page link, make sure to get the compiled version (with the i386 architecture name). Inside the archives, there’s a folder named bin, among others. It is the only one that matters for us, unless you really want man pages. Copy the files from that bin folder to C:\msys\bin. Accept to replace sh.exe, and others if needed.
Now finally you can create a folder for ffmpeg and checkout the latest branch of ffmpeg. Currently it is 0.5, and can be checked out from:
svn://svn.mplayerhq.hu/ffmpeg/branches/0.5
Install it:
./configure --enable-libvorbis --enable-libxvid --enable-libtheora --prefix=c:/mingw --enable-swscale --enable-postproc --enable-pthreads --enable-gpl --enable-memalign-hack make make install
If I remember correctly you may get some errors about undeclared variables. Luckily they are nothing really important, only used in sprintf functions, so replace them with any string of your choice.
X. The very last step: MPlayer!
Check out the source of MPlayer. If you can, check out a release candidate or a „stable” revision. Who knows what might be in nightly builds. Currently the latest release candidate is 1.0rc3, I recommend you using that:
svn://svn.mplayerhq.hu/mplayer/branches/1.0rc3
Get the Windows binary codecs on the MPlayer download page and extract to the codecs dir in the mplayer directory.
Then build MPlayer the following way:
./configure --enable-largefiles --enable-menu --disable-mencoder --enable-static --codecsdir=codecs make
If you want to run it on another computer make sure to add --enable-runtime-cpudetection
, but I guess you don’t want to, otherwise why would you try compiling for yourself? :-)
If everything went well, your brand new mplayer.exe
will be found in the directory you compiled in. Congratulations!
Submit a CommentPlease be polite. We appreciate that.