Using the following scripts you can cross compile gstreamer on Linux host machine (tested on Ubuntu and Debian).
If you don't have a Debian/Ubuntu host and/or you don't want to modify your host, you can try creating a chroot environment, as describrd in GStreamer_Cross_Compile_With_MinGW_In_Chroot_Environment. The following steps should work equally well inside the chroot environment
目录
Ubuntu hardy:
# Binary deb hardy main restricted universe multiverse deb hardy-updates main restricted universe multiverse deb hardy-security main restricted universe multiverse
Debian etch:
deb http://ftp.us.debian.org/debian etch main contrib non-free deb http://ftp.us.debian.org/debian etch-proposed-updates main contrib non-free
root@linux# apt-get update
Ubuntu hardy:
root@linux# apt-get install mingw32 dpkg-dev pkg-config wget libglib2.0-dev unzip libtool automake autoconf m4 gettext cvs flex bison wine git-core subversion
Debian etch:
root@linux# apt-get install mingw32 mingw32-binutils dpkg-dev pkg-config wget libglib2.0-dev bzip2 less unzip libtool automake autoconf m4 gettext cvs flex bison wine git-core subversion
On Ubuntu it might be necessary to force bash as default shell, else some configure scripts might fail (on Debian, bash is already the default shell). However, latest build script patches build infrastructure to arrange forbash where needed, so the following is optional:
root@linux# mv /bin/sh /bin/sh.orig ln -s bash /bin/sh
mnauw@linux> mkdir -p ~/src/win
Obtain cross-env.sh and build_win32_sdk.sh scripts provided below, place them in the build directory and adjust settings incross-env.sh as appropriate, e.g. according to the build root and the particular naming of the cross compiler in your distro.
mnauw@linux> cd ~/src/win bash ./build_win32_sdk.sh preqs deps gst
Arguments given above to the build script direct it to build all basic requirements (e.g. glib), as well as as someext/ dependency libraries (e.g. lame) and finally various GStreamer releases. Other arguments allow building only a specific package. Details on this, as well as many other comments are provided in the scripts.
build_win32_sdk
config.site
build_win32_sdk_tshalif (with some tweaks to force libtool to create shared DLLs)
echo ac_cv_path_CDAUDIO_CONFIG=no >> ~/src/gstreamer-mingw-cross/config.site
cross-env.sh allows adjusting settings to particular situation
build_win32_sdk.sh
下载
#!/bin/bash
# bail out on error
set -e
# bring in environment setup
source cross-env.sh
# feedback
echo "Installation directory: $prefix"
echo
echo "Build flags:"
echo CFLAGS=${CFLAGS}
echo LDFLAGS=${LDFLAGS}
echo CXXFLAGS=${CXXFLAGS}
echo
echo "Building modules: $modules"
# modules to be built as arguments
modules=$*
#########################################################
# preqs: basic dependencies
#########################################################
iconv_version=1.12
gettext_version=0.17
zlib_version=1.2.3
glib_version=2.24.1
# kind of optional, but customary
libxml2_version=2.7.6
# optional, but recommended dependency for native platform sinks/sources
directx_header_version=0.03
# replace preqs with all basic required components
modules=${modules/preqs/iconv gettext zlib glib libxml2 directx}
########################## iconv #################################
if [[ $modules == *iconv* ]] ; then
test -f libiconv-${iconv_version}.tar.gz ||
wget http://mirrors.kernel.org/gnu/libiconv/libiconv-${iconv_version}.tar.gz
rm -rf libiconv-${iconv_version}
tar -xzvf libiconv-${iconv_version}.tar.gz
cd libiconv-${iconv_version}
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix
make
make install
cd ..
fi
########################## gettext #################################
if [[ $modules == *gettext* ]] ; then
test -f gettext-${gettext_version}.tar.gz ||
wget http://mirrors.kernel.org/gnu/gettext/gettext-${gettext_version}.tar.gz
rm -rf gettext-${gettext_version}
tar -xzvf gettext-${gettext_version}.tar.gz
cd gettext-${gettext_version}
# rely on mkdir rather than _mkdir
sed -i 's,return _mkdir,return mkdir,' gettext-tools/gnulib-lib/sys_stat.in.h
# newer mingw might have mkdir declared
# (but with only 1 parameter, so not the expected one)
# force intended result
ac_cv_have_decl_mkdir=no \
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix
# needs some manual patching:
# Makefile that use admitted bash'ism
# but hardcode to /bin/sh
for t in */intl/Makefile* ; do
sed -i 's,^SHELL =.*,SHELL = /bin/bash,' $t
done
# remove stray variables
sed -i 's,^.*rpl_opt.*,,' gettext-tools/woe32dll/gettextlib-exports.c
# do not use undefined variables in #if
# triggers warnings that might force error
for t in */*/*intl.h* ; do \
sed -i 's,__APPLE_CC__,defined __APPLE_CC__ \&\& __APPLE_CC__,' $t ; \
done
# now go
make
make install
cd ..
fi
########################## zlib #################################
if [[ $modules == *zlib* ]] ; then
test -f zlib-${zlib_version}.tar.gz ||
wget http://www.gzip.org/zlib/zlib-${zlib_version}.tar.gz
rm -rf zlib-${zlib_version}
tar zxvf zlib-${zlib_version}.tar.gz
cd zlib-${zlib_version}
# add autotools stuff
cat > configure.ac <<EOF
AC_INIT(zlib, ${zlib_version})
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_PROG_LIBTOOL
AC_LIBTOOL_WIN32_DLL
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
EOF
cat > Makefile.am <<EOF
ACLOCAL_AMFLAGS = -I m4 -I common/m4
lib_LTLIBRARIES = libz.la
libz_la_SOURCES = adler32.c compress.c crc32.c deflate.c gzio.c infback.c \
inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c
libz_la_LDFLAGS = -version-info 1 -no-undefined
include_HEADERS = zlib.h zconf.h
EOF
# remove existing build stuff
rm Makefile
rm Makefile.in
rm configure
# autotool-ize
touch NEWS
touch AUTHORS
libtoolize
aclocal
autoconf
automake --add-missing --copy
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix
make
make install
cd ..
fi
########################## libxml2 ######################
if [[ $modules == *libxml2* ]] ; then
test -f libxml2-${libxml2_version}.tar.gz ||
wget ftp://xmlsoft.org/libxml2/libxml2-${libxml2_version}.tar.gz
rm -rf libxml2-${libxml2_version}
tar -xzvf libxml2-${libxml2_version}.tar.gz
cd libxml2-${libxml2_version}
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix \
--without-python
make
make install
cd ..
fi
########################## glib #########################
# older cross mingw might need updated windns.h
# (take from newer mingw or Cygwin w32api)
if [[ $modules == *glib* ]] ; then
glib_version_mm=${glib_version%.*}
test -f glib-${glib_version}.tar.bz2 ||
wget http://ftp.gnome.org/pub/gnome/sources/glib/${glib_version_mm}/glib-${glib_version}.tar.bz2
rm -rf glib-${glib_version}
tar -xjvf glib-${glib_version}.tar.bz2
cd glib-${glib_version}
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix
make
make install
cd ..
fi
########################## direct X headers #########################
if [[ $modules == *directx* ]] ; then
test -f directx-headers-${directx_header_version}.tar.gz ||
wget http://www.lysator.liu.se/~peda/directx-headers/directx-headers-${directx_header_version}.tar.gz
rm -rf directx-headers-${directx_header_version}
tar -xzvf directx-headers-${directx_header_version}.tar.gz
cd directx-headers-${directx_header_version}/include
patch <<EOF
--- dsound.h 2008-07-31 17:43:23.000000000 +0300
+++ dsound.h 2008-07-31 16:51:58.000000000 +0300
@@ -19,6 +19,11 @@
#ifndef __WINE_DSOUND_H
#define __WINE_DSOUND_H
+/* should be in mmreg.h but mingw version not up-to-date */
+#ifndef WAVE_FORMAT_DOLBY_AC3_SPDIF
+#define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092
+#endif
+
#ifndef DIRECTSOUND_VERSION
#define DIRECTSOUND_VERSION 0x0900
#endif
@@ -1138,7 +1143,7 @@
#ifndef _IKsPropertySet_
#define _IKsPropertySet_
-typedef struct IKsPropertySet IKsPropertySet,*LPKSPROPERTYSET;
+typedef struct IKsPropertySet *LPKSPROPERTYSET;
DEFINE_GUID(IID_IKsPropertySet,0x31EFAC30,0x515C,0x11D0,0xA9,0xAA,0x00,0xAA,0x00,0x61,0xBE,0x93);
EOF
cp *.h ${prefix}/include
cd ../..
fi
#########################################################
# deps: ext/ dependencies
#########################################################
# -good
libpng_version=1.2.29
# -ugly
lame_version=3.98.2
libmad_version=0.15.1b
libmpeg2_version=0.5.1
a52dec_version=0.7.4
# -bad
libdvdnav_version=4.1.2
libdvdcss_version=1.2.9
# replace deps with ext dependency libraries
modules=${modules/deps/libpng libmpeg2 lame a52dec libdvdnav libdvdcss}
# NOTE:
# Whenever possible, most of the dependencies below provide
# a shared lib, i.e. dll
# At choice/leasure/convenience, one might limit the number
# of .dll around by using some more static-only dependencies.
# However, if doing so, libtool must then be appropriately
# 'persuaded' when building plugins to link against those
# (see also later on).
########################## libpng #######################
if [[ $modules == *libpng* ]] ; then
test -f libpng-${libpng_version}.tar.bz2 ||
wget http://prdownloads.sourceforge.net/libpng/libpng-${libpng_version}.tar.bz2
rm -rf libpng-${libpng_version}
tar -xjvf libpng-${libpng_version}.tar.bz2
cd libpng-${libpng_version}
# dll can't do versioned symbols
# override limited configure check
sed -i 's/have_ld_version_script=yes/have_ld_version_script=no/' configure
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix
make
make install
cd ..
fi
########################## lame #########################
if [[ $modules == *lame* ]] ; then
lame_v=$(echo $lame_version | sed 's/\(.*\)\.\(.*\)\.\(.*\)/\1\2-\3/')
# cross-compilation warnings w.r.t. should not be too alarming
# configure will probably figure it out Just Fine
# (but check config.h for the results if wanting to be sure)
test -f lame-${lame_v}.tar.gz ||
wget http://prdownloads.sourceforge.net/lame/lame/lame-${lame_v}.tar.gz
rm -rf lame-${lame_v}
tar -xzvf lame-${lame_v}.tar.gz
cd lame-${lame_v}
# disabling frontend avoids possible gtk mess
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix \
--disable-frontend
make
make install
cd ..
fi
########################## libmad #######################
if false ; then
# disabled:
# configure.ac needs (quite) some patching ...
test -f libmad-${libmad_version}.tar.gz ||
wget http://prdownloads.sourceforge.net/mad/libmad/${libmad_version}/libmad-${libmad_version}.tar.gz
rm -rf libmad-${libmad_version}
tar -xzvf libmad-${libmad_version}.tar.gz
cd libmad-${libmad_version}
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix
make
make install
cd ..
fi
########################## libmpeg2 #########################
if [[ $modules == *libmpeg2* ]] ; then
test -f libmpeg2-${libmpeg2_version}.tar.gz ||
wget http://libmpeg2.sourceforge.net/files/libmpeg2-${libmpeg2_version}.tar.gz
rm -rf libmpeg2-${libmpeg2_version}
tar -xzvf libmpeg2-${libmpeg2_version}.tar.gz
cd libmpeg2-${libmpeg2_version}
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix \
--disable-sdl
make
make install
cd ..
fi
########################## a52dec #######################
if [[ $modules == *a52dec* ]] ; then
test -f a52dec-${a52dec_version}.tar.gz ||
wget http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz
rm -rf a52dec-${a52dec_version}
tar -xzvf a52dec-${a52dec_version}.tar.gz
cd a52dec-${a52dec_version}
./bootstrap
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix \
--enable-shared
make
make install
cd ..
fi
########################## libdvdnav ####################
if [[ $modules == *libdvdnav* ]] ; then
test -f libdvdnav-${libdvdnav_version}.tar.gz ||
wget http://www7.mplayerhq.hu/MPlayer/releases/dvdnav/libdvdnav-4.1.2.tar.gz
rm -rf libdvdnav-${libdvdnav_version}
tar -xzvf libdvdnav-${libdvdnav_version}.tar.gz
cd libdvdnav-${libdvdnav_version}
./autogen.sh noconfig
# avoid building unneeded
# bogus mingw might have stray dlfcn.h
# also: shared will not go down well due to mini lib
# with undefined symbols
ac_cv_path_DOXYGEN=no ac_cv_header_dlfcn_h=no \
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix \
--disable-shared
make
make install
cd ..
# arrange for .pc files to convince gst checks
echo "Creating pkgconfig in ${prefix}/lib/pkgconfig"
cat >${prefix}/lib/pkgconfig/dvdnav.pc <<EOF
prefix=${prefix}
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: libdvdnav
Description: DVD Navigation library
Version: ${libdvdnav_version}
Cflags: -I\${includedir}
Libs: -L\${libdir} -ldvdnav -ldvdread
EOF
# also account for internal libdvdread copy
cat >${prefix}/lib/pkgconfig/dvdread.pc <<EOF
prefix=${prefix}
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: libdvdread
Description: Low level DVD access library
Version: ${libdvdnav_version}
Cflags: -I\${includedir}
Libs: -L\${libdir} -ldvdread
EOF
fi
########################## libdvdcss #########################
if [[ $modules == *libdvdcss* ]] ; then
test -f libdvdcss-${libdvdcss_version}.tar.bz2 ||
wget http://download.videolan.org/pub/libdvdcss/${libdvdcss_version}/libdvdcss-${libdvdcss_version}.tar.bz2
rm -rf libdvdcss-${libdvdcss_version}
tar -xjvf libdvdcss-${libdvdcss_version}.tar.bz2
cd libdvdcss-${libdvdcss_version}
# ./bootstrap
# avoid building unneeded
ac_cv_path_LATEX=no ac_cv_path_DOXYGEN=no \
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix
# src/Makefile.am (wrongly) omits -no-undefined
# so shared lib might not get built unless libtool is forced ...
sed -i 's,build_libtool_libs=no,build_libtool_libs=yes,' libtool
make
make install
ln -sf libdvdcss-2.dll ${prefix}/bin/libdvdcss.dll
cd ..
fi
#########################################################
# gst: gstreamer fdo releases
#########################################################
checkpre () {
echo $1 | egrep '^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$' > /dev/null && echo pre/
}
export_plugin_desc () {
sed -i 's/plugin_desc\\\$\\\$/plugin_desc.*/' configure
}
# obviously all sorts of variations are possible;
# e.g. using git checkouts rather than (pre-)release tarballs,
# but let's stick to the latter here just to illustrate
# (and is good enough to test those (pre-)releases.
core_version=0.10.32
base_version=0.10.32
good_version=0.10.27
ugly_version=0.10.17
bad_version=0.10.21
ffmpeg_version=0.10.11
# replace deps with ext dependency libraries
modules=${modules/gst/core base good ugly bad}
# in (almost) each)case below, some additional explicit
# --disable-... are likely needed to avoid some checks
# confusing the build system with the host system
# some needed patching:
# - ensure plugin dll exports gst_plugin_desc
# - persuade libtool to also link a (dynamic dll) plugin
# to a real static lib (rather than only an import lib),
# e.g. some directx libs (or otherwise only static compiled
# dependency lib)
########################## core #######################
if [[ $modules == *core* ]] ; then
echo gstreamer ...
test -f gstreamer-${core_version}.tar.bz2 ||
wget http://gstreamer.freedesktop.org/src/gstreamer/$(checkpre ${core_version})gstreamer-${core_version}.tar.bz2
rm -rf gstreamer-${core_version}
tar -xjvf gstreamer-${core_version}.tar.bz2
cd gstreamer-${core_version}
# NOCONFIGURE=1 ./autogen.sh
export_plugin_desc
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix
make
make install
cp $(find . -name '*.dll.def') $prefix/lib
cd ..
fi
########################## base #######################
if [[ $modules == *base* ]] ; then
echo gst-plugins-base ...
test -f gst-plugins-base-${base_version}.tar.bz2 ||
wget http://gstreamer.freedesktop.org/src/gst-plugins-base/$(checkpre ${base_version})gst-plugins-base-${base_version}.tar.bz2
rm -rf gst-plugins-base-${base_version}
tar -xjvf gst-plugins-base-${base_version}.tar.bz2
cd gst-plugins-base-${base_version}
# NOCONFIGURE=1 ./autogen.sh
export_plugin_desc
lt_cv_deplibs_check_method=pass_all \
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix \
--disable-ogg \
--disable-theora \
--disable-vorbis \
--disable-x
make
make install
cp $(find . -name '*.dll.def') $prefix/lib
cd ..
fi
########################## good #######################
if [[ $modules == *good* ]] ; then
test -f gst-plugins-good-${good_version}.tar.bz2 ||
wget http://gstreamer.freedesktop.org/src/gst-plugins-good/$(checkpre ${good_version})gst-plugins-good-${good_version}.tar.bz2
tar -xjvf gst-plugins-good-${good_version}.tar.bz2
cd gst-plugins-good-${good_version}
# NOCONFIGURE=1 ./autogen.sh
export_plugin_desc
lt_cv_deplibs_check_method=pass_all \
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix \
--disable-aalib \
--disable-esd \
--disable-shout2 \
--disable-oss4 \
--disable-x
make
make install
cd ..
fi
########################## ugly #######################
if [[ $modules == *ugly* ]] ; then
test -f gst-plugins-ugly-${ugly_version}.tar.bz2 ||
wget http://gstreamer.freedesktop.org/src/gst-plugins-ugly/$(checkpre ${ugly_version})gst-plugins-ugly-${ugly_version}.tar.bz2
tar -xjvf gst-plugins-ugly-${ugly_version}.tar.bz2
cd gst-plugins-ugly-${ugly_version}
# NOCONFIGURE=1 ./autogen.sh
export_plugin_desc
lt_cv_deplibs_check_method=pass_all \
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix
make
make install
cd ..
fi
########################## bad #######################
if [[ $modules == *bad* ]] ; then
test -f gst-plugins-bad-${bad_version}.tar.bz2 ||
wget http://gstreamer.freedesktop.org/src/gst-plugins-bad/$(checkpre ${bad_version})gst-plugins-bad-${bad_version}.tar.bz2
tar -xjvf gst-plugins-bad-${bad_version}.tar.bz2
cd gst-plugins-bad-${bad_version}
# NOCONFIGURE=1 ./autogen.sh
export_plugin_desc
lt_cv_deplibs_check_method=pass_all \
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix \
--disable-sdl \
--disable-acm
make
make install
cd ..
fi
########################## ffmpeg #######################
if [[ $modules == *ffmpeg* ]] ; then
test -f gst-ffmpeg-${ffmpeg_version}.tar.bz2 ||
wget http://gstreamer.freedesktop.org/src/gst-ffmpeg/$(checkpre ${ffmpeg_version})gst-ffmpeg-${ffmpeg_version}.tar.bz2
tar -xjvf gst-ffmpeg-${ffmpeg_version}.tar.bz2
cd gst-ffmpeg-${ffmpeg_version}
# NOCONFIGURE=1 ./autogen.sh
export_plugin_desc
lt_cv_deplibs_check_method=pass_all \
./configure \
--host=${host} \
--build=${build} \
--prefix=$prefix
make
make install
cd ..
fi