Howto Compile Mplayer with MinGW

02.01.2005 Sascha Sommer – initial revision
13.02.2005 Stefan Gürtler <helfmir at surfeu.de> – Enhanced step 5 including building/installing x264
           Sascha Sommer – ogg/vorbis step can be skipped, –enable-runtime-cpudetection is only needed when
                           using the executable on different systems
                           other small fixes pointed out by Reimar Döffinger and Wen-King Su <
wen-king@myri.com>

 

Once finished this should become a howto that will explain the steps necessary to setup the toolchain to
compile your own versions of MPlayer on MinGW
similar to the one in the packages found at http://www.mplayerhq.hu/MPlayer/releases/win32-beta

Step 1 Mingw and msys
Download the latest versions of MinGW and msys from
http://www.mingw.org/download.shtml

The versions used in this document are
MinGW-3.1.0-1.exe
MSYS-1.0.10.exe

Then install MinGW and afterwards msys.

Answer
"Do you wish to continue with the post install? [yn ]"
and
"Do you have MinGW installed? [yn ]"
with y and give the path to your mingw dir in the next question. (c:/mingw if you did not alter the path during
the mingw setup)

After the installation is finished, open a msys shell (you can find an icon for it on your desktop).

The following steps assume that you download the packages to your msys home dir, for me that is in c:\msys\home\useranme
where username is my windows username.

Step 2 directx headers
Get the directx header package at
http://www.mplayerhq.hu/MPlayer/releases/win32-beta/contrib/dx7headers.tgz

As alternative you can also use the modified wine headers reimar posted to the cygwin list.

Extract the headers and move them to your mingw inlucde dir (c:\mingw\include)
To do this use the following commands in your msys shell
tar -xvvzf dx7headers.tgz
mv *.h c:/mingw/include

Note: In this tutorial I install all packages into the mingw tree, it might probably be better to put all
extra libraries and headers
into a seperate directory and pass this directory with the –with-extraincdir and –with-extralibdir
switches to configure
Furthermore I’m using static linking to prevent problems caused by different dll versions.
Omitting the –disable-shared from the configure commands will help you to build smaller exes that
require the various dlls to be installed.

Step 2 ogg and vorbis
Newer version of MPlayer already include the necessary sources, you can therefore skip this step.
Go to http://www.vorbis.com/download.psp
Select "Unix / Linux" as operating system
Then download the libvorbis and libogg .tar.gz sources
from the Libraries section
Also get the patch http://mplayerhq.hu/MPlayer/releases/win32-beta/contrib/libogg-mingw32.diff

extract the archive:

tar -xvvzf libogg-1.1.tar.gz

change to the dir containing the sources:
cd libogg-1.1

Apply the mingw build patch:
patch -p0 <../libogg-mingw32.diff

Then 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
tar -xvvzf libvorbis-1.0.1.tar.gz
cd libvorbis-1.0.1
./configure –prefix=c:/mingw –disable-shared
make
make install
cd

Step 3 freetype (for osd font rendering)
First install libiconv from
http://www.gnu.org/software/libiconv/

Get the sources then
tar -xvvzf libiconv-1.9.1.tar.gz
cd libiconv-1.9.1
./configure –prefix=c:/mingw –disable-shared
make
make install
cd

Then get the latest freetype2 source package from
http://sourceforge.net/project/showfiles.php?group_id=3157

tar -xvvjf freetype-2.1.9.tar.bz2
cd freetype-2.1.9
make
make install
cd

Step 4 zlib, libregif, libpng, libjpeg
zlib is needed for some mov files with compressed headers the others to play/encode png/jpeg/gif files

Sources are available from:
http://www.gzip.org/zlib/
http://armory.nicewarrior.org/projects/libregif/
http://sourceforge.net/project/showfiles.php?group_id=5624
http://www.ijg.org/

tar -xvvzf zlib-1.2.1.tar.gz
cd zlib-1.2.1
./configure –prefix=c:/mingw
make
make install
cd

tar -xvvzf libpng-1.2.8-config.tar.gz
cd libpng-1.2.8-config
./configure –prefix=c:/mingw –disable-shared
make
make install
cd

tar -xvvzf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure –prefix=/mingw/ –enable-static
make
cp .libs/libjpeg.a c:/mingw/lib/
cp jpeglib.h jconfig.h jmorecfg.h c:/mingw/include/
cd

tar -xvvzf libregif-4.1.5.tar.gz
cd libregif-4.1.5
./configure –prefix=c:/mingw
make
make install
cd

Step 5 lame, xvid and x264

Get the nasm sources from
http://sourceforge.net/project/showfiles.php?group_id=6208

tar -xvvzf nasm-0.98.38.tar.gz
cd nasm-0.98.38
./configure –prefix=c:/mingw
make
mkdir c:/mingw/man/man1
make install
cd

Install lame from http://lame.sourceforge.net/download/download.html
tar -xvvzf lame-3.96.1.tar.gz
cd lame-3.96.1
./configure –prefix=c:/mingw –disable-shared –disable-decoder
make
make install
cd

Now get http://www.xvid.org/downloads.html
tar -xvvzf xvidcore-1.0.3.tar.gz
cd xvidcore-1.0.3/build/generic
./configure –prefix=c:/mingw –disable-shared
make
make install
mv c:/mingw/lib/xvidcore.a c:/mingw/lib/libxvidcore.a

Get x264 svn checkout from videolan.org. Either use cygwin svn client or
download official ziped win32 binaries from
http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91.
Unpack and copy all files in /bin somewhere into your PATH, e.g. /mingw/bin

svn co svn://svn.videolan.org/x264/trunk x264
cd x264/build/cygwin
make
cp bin/libx264.a /mingw/lib
cd ../../
cp x264.h /mingw/include/

Step 6 live.com rtsp streaming support
Get the sources
http://www.live.com/liveMedia/public/

tar -xvvzf live.2004.12.29.tar.gz       (got some errors from tar here but the build worked nevertheless)
cd live
genMakefiles mingw
make

Step 7 MPlayer
For my build I’m using a cvs checkout using cygwin, but cvs snapshots, wincvs or release tarballs should
work, too.

In the cygwin shell
cd to your msys home dir

cvs -d:pserver:anonymous@mplayerhq.hu:/cvsroot/mplayer login
cvs -z3 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/mplayer co -P main

When asked for a password, just hit enter. A directory named main will be created.

Now checkout ffmpeg

cd main
cvs -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg login
cvs -z3 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg  co -Pd libavcodec ffmpeg/libavcodec
cvs -z3 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg  co -Pd libavformat ffmpeg/libavformat

All the sources should be there now.

cd main
./configure –enable-runtime-cpudetection –with-codecsdir=codecs –enable-static –with-livelibdir=/home/username/live
(make sure you use the right path for the –with-livelibdir option, if you plan to use the executable only on the computer on which you are compiling
you can leave out –enable-runtime-cpudetection)
make

If everything went well your first mplayer.exe can be found in the main dir now.

 

Detail :MPlayer-MinGW-Howto.txt

8 responses to “Howto Compile Mplayer with MinGW

Leave a comment