gstreamer Win32_Cross_Compiling_With_Mingw



Win32_Cross_Compiling_With_Mingw

Using the following scripts you can cross compile gstreamer on Linux host machine (tested on Ubuntu and Debian).

1. Pre-requisites

1.1. Install required packages

  1. Modify /etc/apt/source.list (if necessary):
    • 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    
  2. Install packages
    • 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

1.2. Make 'bash' your default shell (optional - Ubuntu)

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

2. Setup cross-compile root

  1. Create a directory where all cross compilation will take place:
    mnauw@linux> mkdir -p ~/src/win
  2. 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.

3. Build

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.

4. Miscellaneous

  1. David Schleef's scripts (local copy):
  2. Modified version of build_win32_sdk and config.site:
    • build_win32_sdk_tshalif (with some tweaks to force libtool to create shared DLLs)

    • An example forcing gstreamer's configure script to ignore host-installed 'libcdaudio-dev':
      echo ac_cv_path_CDAUDIO_CONFIG=no >> ~/src/gstreamer-mingw-cross/config.site
  3. Latest version of build scripts:


附件 'cross-env.sh'

下载

 #!/bin/sh 


export winroot=${HOME}/src/win
export prefix=${winroot}/build

export PKG_CONFIG_LIBDIR=${prefix}/lib/pkgconfig/
export PKG_CONFIG_PATH=
# export CONFIG_SITE=${winroot}/config.site
# export MAKEFLAGS='-j 4'

# mileage may vary
export PATH=/opt/cross/bin:$PATH
# deal with bash'ism in script, if not default sh
export CONFIG_SHELL=/bin/bash

# new(er) _mingw.h seems to neglect setting this (properly)
# MINGW_CFLAGS="-D__MINGW32_MAJOR_VERSION=3 -D__MINGW32_MINOR_VERSION=15"

export CFLAGS="-g -O2 -I${prefix}/include -D_WIN32_WINNT=0x0501 $MINGW_CFLAGS $CFLAGS"
export CXXFLAGS="-g -O2 -I${prefix}/include $CXXFLAGS"
export LDFLAGS="-g -O2 -L${prefix}/lib  $LDFLAGS"

# a few variations out there
# one will do obviously (may or may not need PATH addition)
export host=i586-mingw32msvc
# export host=i386-mingw32msvc
# export host=i686-pc-mingw32
export build=i486-linux-gnu

export confargs="--host=${host} --build=${build} --prefix=$prefix"

附件 '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


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值