Monday, January 14, 2013

Compiling MPlayer


After we have successfully set up the MSYS environment, now we can start compiling our libraries and software. Before we start compiling the libraries needed in building MPlayer, additional tools are needed to complete the task.


SVN & Git:

Download SVN from here: svn-win32-1.6.20.zip and extract to 'c:/dev/msys/var'. Rename the extracted folder 'svn-win32-1.6.20' to 'svn'.

Download Git from here: PortableGit-1.8.0-preview20121022.7z and extract to 'c:/dev/msys/var/git'.

Make a new file (plain text) called 'svn' (without quote & without any extension) in 'c:/dev/msys/bin' with the following contents:
#! /bin/sh
exec '/usr/var/svn/bin/svn.exe' "$@"

Likewise, make another file (plain text) called 'git' (without quote & without any extension) in 'c:/dev/msys/bin' with the following contents:
#! /bin/sh
exec '/usr/var/git/bin/git.exe' "$@"


Extra tools:

We need yasm to compile x264 and MPlayer. Download yasm-1.2.0-win64.exe and copy (+ rename) to 'c:/dev/mingw/bin/yasm.exe'



Updating the environment:

Add in 'c:/msys/etc/fstab':
c:/dev/mingw /mingw
c:/dev/mplayer-libs /mplayer

Add in 'c:/dev/msys/etc/profile':
export CPPFLAGS="-I/mplayer/include"
export CXXFLAGS="-I/mplayer/include"
export LDFLAGS="-L/mplayer/lib"
export PATH="$PATH:/mplayer/bin"
export PKG_CONFIG_PATH="/mplayer/lib/pkgconfig"

These variables are needed because we are gonna install all the compiled libs in a nonstandard path.



Compiling the libraries:

dlfcn-win32-r19
https://dlfcn-win32.googlecode.com/files/dlfcn-win32-r19.tar.bz2
cd dlfcn-win32-r19
./configure --prefix=/mplayer --cc=gcc --libdir=/mplayer/lib --incdir=/mplayer/include
make && make install
libcaca-0.99.beta18
http://caca.zoy.org/raw-attachment/wiki/libcaca/libcaca-0.99.beta18.tar.gz
patch: libcaca-0.99.beta18_mingw_static.diff
cd libcaca-0.99.beta18
patch -p1 <../libcaca-0.99.beta18_mingw_static.diff
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-cxx --disable-shared
make && make install
libpng-1.5.13
http://sourceforge.net/projects/libpng/files/libpng15/1.5.13/libpng-1.5.13.tar.bz2/download
cd libpng-1.5.13
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
libmng-1.0.10
http://sourceforge.net/projects/libmng/files/libmng-devel/1.0.10/libmng-1.0.10.tar.bz2/download
patch: libmng-1.0.10_without_jpeg.diff
cd libmng-1.0.10
patch -p1 <../libmng-1.0.10_without_jpeg.diff
make -f makefiles/makefile.mingw prefix=/mplayer install
jpeg-8d
http://www.ijg.org/files/jpegsrc.v8d.tar.gz
cd jpeg-8d
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
openjpeg-1.5.1
http://openjpeg.googlecode.com/files/openjpeg-1.5.1.tar.gz
patch: openjpeg-1.5.1_mingw_static.diff
cd openjpeg-1.5.1
patch -p1 <../openjpeg-1.5.1_mingw_static.diff
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
giflib-4.1.6
http://sourceforge.net/projects/giflib/files/giflib-4.x/giflib-4.1.6.tar.bz2/download
patch:  add '#include <malloc.h>' in 'lib/gif_hash.c'
cd giflib-4.1.6
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
cd lib
make && make install
libbluray-0.2.3
http://download.videolan.org/pub/videolan/libbluray/0.2.3/libbluray-0.2.3.tar.bz2
cd libbluray-0.2.3
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-examples --disable-shared
make && make install
libcdio-0.83
http://ftp.gnu.org/gnu/libcdio/libcdio-0.83.tar.bz2
patch: libcdio-0.83_mingw64_fix.diff
cd libcdio-0.83
patch -p1 <../libcdio-0.83_mingw64_fix.diff
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-cxx --disable-example-progs --disable-shared
make && make install
freetype-2.4.11
http://sourceforge.net/projects/freetype/files/freetype2/2.4.11/freetype-2.4.11.tar.bz2/download
cd freetype-2.4.11
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
libiconv-1.14
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
expat-2.1.0
http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz/download
cd expat-2.1.0
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
fontconfig-2.5.0
http://freedesktop.org/software/fontconfig/release/fontconfig-2.5.0.tar.gz
patch: fontconfig-2.5.0_mingw_static.diff
cd fontconfig-2.5.0
patch -p1 <../fontconfig-2.5.0_mingw_static.diff
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-docs --disable-shared
make && make install
fribidi-0.19.5
http://fribidi.org/download/fribidi-0.19.5.tar.bz2
patch: fribidi-0.19.5_mingw_static.diff
cd fribidi-0.19.5
patch -p1 <../fribidi-0.19.5_mingw_static.diff
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
enca-1.14
http://dl.cihar.com/enca/enca-1.14.tar.bz2
cd enca-1.14
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
zlib-1.2.7
http://zlib.net/zlib-1.2.7.tar.bz2
patch: zlib-1.2.7_disable_shared.diff
cd zlib-1.2.7
patch -p1 <../zlib-1.2.7_disable_shared.diff
make prefix=/mplayer libz.a -f win32/Makefile.gcc install
bzip2-1.0.6
http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
patch: bzip2-1.0.6_mingw_static.diff
cd bzip2-1.0.6
patch -p1 <../bzip2-1.0.6_mingw_static.diff
make
install -m 755 bzip2.exe /mplayer/bin/bzip2.exe
install -m 755 bzip2.exe /mplayer/bin/bunzip2.exe
install -m 644 bzlib.h /mplayer/include
install -m 644 libbz2.a /mplayer/lib
lzo-2.06
http://www.oberhumer.com/opensource/lzo/download/lzo-2.06.tar.gz
patch: lzo-2.06_missing_defined.diff
cd lzo-2.06
patch -p1 <../lzo-2.06_missing_defined.diff
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
libmad-0.15.1b
http://sourceforge.net/projects/mad/files/libmad/0.15.1b/libmad-0.15.1b.tar.gz/download
patch: remove ' -fforce-mem' on line 19,102 in 'configure'
cd libmad-0.15.1b
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
twolame-0.3.13
http://sourceforge.net/projects/twolame/files/twolame/0.3.13/twolame-0.3.13.tar.gz/download
patch: twolame-0.3.13_mingw_static.diff
cd twolame-0.3.13
patch -p1 <../twolame-0.3.13_mingw_static.diff
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
libogg-1.3.0
http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.xz
cd libogg-1.3.0
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
libvorbis-1.3.3
http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.xz
cd libvorbis-1.3.3
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-examples --disable-shared
make && make install
speex-1.2rc1
http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz
cd speex-1.2rc1
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
libtheora-1.1.1
http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.xz
cd libtheora-1.1.1
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-examples --disable-shared
make && make install
gsm-1.0.13
http://osxwinebuilder.googlecode.com/files/gsm-1.0.13.tar.gz
patch: gsm-1.0.13_mingw.diff
cd gsm-1.0.13
patch -p1 <../gsm-1.0.13_mingw.diff
make
install -d /mplayer/include/gsm
install -m 644 inc/gsm.h /mplayer/include/gsm
install -m 644 lib/libgsm.a /mplayer/lib
mpg123-1.14.4
http://sourceforge.net/projects/mpg123/files/mpg123/1.14.4/mpg123-1.14.4.tar.bz2/download
patch: add '#define EOVERFLOW E2BIG' on line 33 in 'src/libmpg123/lfs_wrap.c'
cd mpg123-1.14.4
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
a52dec-0.7.4
http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz
cd a52dec-0.7.4
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
libdca-0.0.5
http://download.videolan.org/pub/videolan/libdca/0.0.5/libdca-0.0.5.tar.bz2
patch: add another '&' on line 669 in 'libdca/parse.c'
cd libdca-0.0.5
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
opus-1.0.1
http://downloads.xiph.org/releases/opus/opus-1.0.1.tar.gz
cd opus-1.0.1
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
libsndfile-1.0.25
http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.25.tar.gz
cd libsndfile-1.0.25
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
libbs2b-3.1.0
http://sourceforge.net/projects/bs2b/files/libbs2b/3.1.0/libbs2b-3.1.0.tar.bz2/download
cd libbs2b-3.1.0
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
live.2013.01.05
http://www.live555.com/liveMedia/public/live.2013.01.05.tar.gz
patch: live.2013.01.05_mingw_mplayer_static.diff
cd live
patch -p1 <../live.2013.01.05_mingw_mplayer_static.diff
./genMakefiles mingw
make CC=gcc
make prefix=/mplayer install
rtmpdump-2.4
http://rtmpdump.mplayerhq.hu/download/rtmpdump-2.4.tar.gz
cd rtmpdump-2.4
make prefix=/mplayer mandir=/mplayer/share/man SYS=mingw CRYPTO= CRYPTO_REQ= SHARED=no install
opencore-amr-0.1.3
http://sourceforge.net/projects/opencore-amr/files/opencore-amr/opencore-amr-0.1.3.tar.gz/download
cd opencore-amr-0.1.3
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
xvidcore-1.3.2
http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.bz2
patch: xvidcore-1.3.2_mingw_static.diff
cd xvidcore-1.3.2/build/generic
patch -p1 <../xvidcore-1.3.2_mingw_static.diff
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-assembly
make && make install
x264
git clone git://git.videolan.org/x264.git x264
ftp://ftp.tnt.uni-hannover.de/pub/jvt/sequences/waterfall_cif.yuv
* rename 'waterfall_cif.yuv' to 'waterfall_cif_352x288.yuv' and put it in 'x264' dir
cd x264
./configure --prefix=/mplayer --host=x86_64-w64-mingw32 --enable-win32thread --enable-static
make fprofiled VIDS=waterfall_cif_352x288.yuv
make && make install
dirac-1.0.2
http://sourceforge.net/projects/dirac/files/dirac-codec/Dirac-1.0.2/dirac-1.0.2.tar.gz/download
patch: remove 'util' on line 221 in 'Makefile.in'
cd dirac-1.0.2
export CXXFLAGS=-Wno-error
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-mmx --disable-shared
make && make install
orc-0.4.16
http://code.entropywave.com/download/orc/orc-0.4.16.tar.gz
cd orc-0.4.16
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
schroedinger-1.0.11
http://diracvideo.org/download/schroedinger/schroedinger-1.0.11.tar.gz
patch: remove 'testsuite' on line 294 in 'Makefile.in'
patch: add '#include <process.h>' in 'schroasync-win32.c'
cd schroedinger-1.0.11
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
libvpx-v1.0.0
http://webm.googlecode.com/files/libvpx-v1.0.0.tar.bz2
cd libvpx-v1.0.0
./configure --prefix=/mplayer --target=x86_64-win64-gcc --disable-examples --disable-shared
make && make install
nut
svn co svn://svn.mplayerhq.hu/nut/src/trunk nut
cd nut
make CC=gcc
make PREFIX=/mplayer install
lame-3.99.5
http://sourceforge.net/projects/lame/files/lame/3.99/lame-3.99.5.tar.gz/download
cd lame-3.99.5
./configure --prefix=/mplayer --build=x86_64-w64-mingw32 --disable-shared
make && make install
vstream-client-1.2.1.1
http://vstream-client.googlecode.com/files/vstream-client-1.2.1.1.tar.bz2
cd vstream-client-1.2.1.1
LDFLAGS=-Wl,--disable-stdcall-fixup ./configure --prefix=/mplayer
make CC=gcc
make install

Compile MPlayer:

Get the latest MPlayer source using svn:
svn co svn://svn.mplayerhq.hu/mplayer/trunk mplayer-src
Then cd to the 'mplayer-src' dir and download the FFmpeg source:
cd mplayer-src
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
Use this patch to update the detection routine of libraries (libcdio, librtmp, vstream-client & live555) in 'configure' and some other fixes:
patch -p1 <../mplayer-svn-35738_misc_fix.patch
Now, we can start building MPlayer:
./configure --prefix=/mplayer --target=x86_64-mingw32 --enable-menu --enable-static
make -j2 && make install

The next time you want to update MPlayer & FFmpeg source, execute:
cd mplayer-src
svn up && cd ffmpeg && git pull && cd ..
Everytime you want to rebuild MPlayer, clean the directory first:
cd mplayer-src
make distclean

Downloads:

mplayer-svn-r37181-421b21c-4.8.2-x86_64.7z

mplayer-svn-r36443-9b07d34-4.8.2-x86_64.7z


Saturday, January 12, 2013

Setting Up MSYS-MinGW Environment

Installing MinGW-w64

Before setting up an MSYS environment, we must install MinGW-w64 first. You can get the official mingw-w64 toolchains like rubenvb's or ray_linn's, or from others such as:

1. Komisar
2. XvidVideo
3. MinGW-builds
4. NevCairiel (my chosen toolchains coz all were built as static)

Now, get the latest mingw-w64-gcc toolchains: mingw-w64-gcc-4.7.2-stable-r5.7z
Extract to 'c:/dev/mingw' or any other preferred location.

We are gonna be using the x86_64 toolchains in this example. Change the name of the 'bin' folder in 'c:/dev/mingw' to 'bin32'. Make a new folder called 'bin' and move all 'x86_64-w64-mingw32-*.exe' from the previously renamed 'bin32' folder to the 'bin' folder. Then rename all the exe in 'bin' by removing 'x86_64-w64-mingw32-' from the filename.

Some more house cleaning needed (this is optional):
* in 'c:/dev/mingw/x86_64-w64-mingw32/bin':
remove bunzip2.exe, bzcat.exe, bzip2.exe, bzip2recover.exe & bz*

* in 'c:/dev/mingw/x86_64-w64-mingw32/include':
remove bzlib.h, pthread.h, sched.h, semaphore.h, zconf.h & zlib.h

* in 'c:/dev/mingw/x86_64-w64-mingw32/lib':
remove libbz2.a, libpthreadGC2.a & libz.a


Now the mingw-w64 toolchains is complete.


Installing MSYS

Download the latest MSYS toolchains here: MSYS-20111123.zip and extract to 'c:/dev'.

Add this to 'c:/dev/msys/etc/fstab':
'c:/dev/mingw /mingw' (without quote)

Make a shortcut of 'c:/dev/msys/msys.bat' to the desktop (or anywhere you like). Set Administrator rights to the shortcut (right click>Properties>Shortcut>Advanced...> tick 'Run as administrator').

Test your msys & mingw installation by running the shortcut. Type 'gcc -v' and it should output:
Using built-in specs.
COLLECT_GCC=c:\dev\mingw\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/dev/mingw//bin/../libexec/gcc/x86_64-w64-mingw32/4.7.2\\/lto-wrapper.exe
Target: x86_64-w64-mingw32

......
gcc version 4.7.2 (GCC)


Updating some tools in MSYS..

[ make ]
The make.exe from the bundled msys package is old (v3.81) & sometimes buggy. We gonna update it to a more updated version, that is make-3.82. Get my precompiled make-3.82 for msys here:
make-3.82-1_msys.7z

Extract it to 'c:/dev/msys'

[ pkg-config ]
Get my precompiled static pkg-config-0.25 for msys here:
pkg-config-0.25-1_msys.7z

Extract it to 'c:/dev/msys'

[ autotools ]
Sometimes we need to use these autotools in order to compile a library or software:
autoconf-2.68-1-msys-1.0.17-bin.tar.lzma
automake-1.11.1-1-msys-1.0.13-bin.tar.lzma
libtool-2.4-1-msys-1.0.15-bin.tar.lzma
libltdl-2.4-1-msys-1.0.15-dll-7.tar.lzma

The official msys libtool has a bogus warning regarding moved libs when compiling. Get my precompiled libtool-2.4.2 (with bogus warning fix) for msys here:
libtool-2.4.2-1_msys.7z

Extract it to 'c:/dev/msys'


Now the msys environment is complete.