Cross-compile Gstreamer-1.0 from Fedora Linux 64-bit to Windows 64-bit
Update. Windows binaries of GTK+-3.14.0, Gstreamer-1.4.4, Python3, pygtk3 gobject-introspection PyGObject (aka PyGI) are available from here, so this guide is not necessary (unless the latest version of Gstreamer without PyGI is desired)
This handy little guide catalogues the adventures of building a minimal Windows version of GStreamer-1.0 on Linux, (without PyGI, which can only be built on Windows). GStreamer-0.10 is end-of-life, so we won't be discussing that. For those who need the Python stuff, but do not want to download the above binaries, Start with building Python3 on Windows. Visual Studio 2010 Professional Edition and Python 2.7-ish is required to build 64-bit Python3. Express Edition can do 32 bit. Now away, go!
The rest of this guide is for Fedora Linux. What good is a Windows version of Gstreamer on Fedora? We can use the comfortable Linux desktop and cross-build system to buid apps for both Windows and Linux, that's why. And then we can test our apps in the wine windows emulator, and make sure everything works the same without needing to use a separate Windows machine.
Fedora Packages
Geting mingw64. This is not the most exhaustive, nor the most minimal install of Mingw64. It's simply what we had on our system.
yum -y install mingw64-binutils mingw64-bzip2 mingw64-cairo mingw64-cpp mingw64-crt \
mingw64-expat mingw64-fftw mingw64-flac mingw64-flac-tools mingw64-fontconfig \
mingw64-freetype mingw64-gcc mingw64-gcc-c++ mingw64-gdb mingw64-gdk-pixbuf \
mingw64-gettext mingw64-glib2 mingw64-gtk2 mingw64-harfbuzz mingw64-headers mingw64-icu \
mingw64-jasper mingw64-libffi mingw64-libjpeg-turbo mingw64-libpng mingw64-libsoup \
mingw64-libtiff mingw64-libxml2 mingw64-orc mingw64-pango mingw64-pixman \
mingw64-pkg-config mingw64-sqlite mingw64-termcap mingw64-win-iconv mingw64-winpthreads \
mingw64-zlib mingw-binutils-generic mingw-w64-tools mingw64-libgcrypt mingw64-curl \
mingw64-plibc
Notice: Do not use root or sudo administrator permissions for any of the make install steps. This howto installs them to the default .wine folder in the user's $HOME directory, which should not require any special permissions. Do not use root or sudo to run wine, nor to do any tests. That's now how any of this works. As a matter of fact, it would be better to log in as an unpriviliged dev user, or chroot sandbox.
This is just a temporary test build walkthrough. Of course there are no guarantees, but if followed correctly, no changes should happen to anything on the Linux development platform. For something more permanant, you could go ahead and re-compile some of these dependencies into Linux's Mingw64 itself from a different shell, and using mingw64-make but that is beyond the scope of this particular agenda.
This will set up a "safe" cross-build environment.
mingw64-env
export PREFIX="$HOME/.wine/drive_c/gst64"
export EPREFIX="$PREFIX"
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"
export GST_PLUGIN_PATH_1_0="$PREFIX/lib/gstreamer-1.0"
export LDFLAGS=-L"$PREFIX/lib -lpthread"
export CFLAGS="-mthreads -pthread -D_WIN32_WINNT=0x0501 -DWINVER=0x0501 -I$PREFIX/include"
export PYTHON=$HOME/.wine/drive_c/Python27/python.exe
export CFLAGS="$CFLAGS -I$HOME/.wine/drive_c/Python27/include"
export LDFLAGS="$LDFLAGS -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib"
export LIBS=-L$HOME/.wine/drive_c/Python27/libs
export SWIG=$HOME/.wine/drive_c/swigwin-3.0.2/swig.exe
export OPTS="--build=x86_64 --host=x86_64-w64-mingw32 --sysconfdir="$PREFIX/etc" --prefix="$PREFIX" \
--exec-prefix="$EPREFIX" --bindir="$EPREFIX/bin" --libdir="$EPREFIX/lib" --libexecdir="$EPREFIX/libexec" \
--sbindir="$EPREFIX/sbin" --sharedstatedir="$EPREFIX/lib" --datarootdir="$EPREFIX/share" \
--datadir="$PREFIX/share" --includedir="$PREFIX/include" --infodir="$PREFIX/share/info" \
--mandir="$PREFIX/share/man" --localstatedir="$PREFIX/var""
mkdir -p $HOME/dev/win
cd $HOME/dev/win
common build commands
make distclean
./autogen.sh $OPTS
./configure $OPTS
make -j16
make install
Download to $HOME/dev/win and build in order.
- orc cgit.freedesktop.org/gstreamer/orc/
- ogg, vorbis and theora www.xiph.org/downloads/
- lame sourceforge.net/projects/lame/files/latest/download?source=files
- x264, x265 www.videolan.org/developers/x264.html ./configure $OPTS --enable-shared
- opencv opencv.org/
- libsndfile www.mega-nerd.com/libsndfile/
- pygobject3 ftp.gnome.org/pub/GNOME/sources/pygobject/3.0/
- gstreamer cgit.freedesktop.org/gstreamer/
- gst-plugins-base
- gst-plugins-good
- gst-plugins-bad
- gst-plugins-ugly
Fixing Errors Hints
Some projects require cmake.yum -y install cmake
x265: use cmake Create a toolchain file for mingw64 development www.cmake.org/Wiki/CmakeMingw
rm -rf CMakeCache.txt CMakeFiles/
cmake ../source -DCMAKE_TOOLCHAIN_FILE=$HOME/dev/win64.cmake -DCMAKE_INSTALL_PREFIX=$PREFIX
mingw64-make -j16
mingw64-make install
opencv: deps docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#windows-installation
ld: cannot find -lRunTmChk ref: answers.opencv.org/question/40159/cannot-compile-opencv-30/
rerun cmake -DWITH_IPP=OFF
cmake . -DCMAKE_TOOLCHAIN_FILE=$HOME/dev/win64.cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DWITH_IPP=OFF
libtheora: problems stackoverflow.com/questions/18963814/cross-compile-libtheora-with-mingw lists.gnupg.org/pipermail/gnupg-devel/2013-April/027585.html .libs/libtheoradec-1.dll.def: file format not recognized; treating as linker script
sed -i 's/\(1q \\$export_symbols\)/\1|tr -d \\\\\\\"\\r\\\\\\\"/' libtool
mingw64-make
png2theora.c:467: undefined reference to png_sizeof
Change png_sizeof to sizeof lists.gnu.org/archive/html/discuss-gnustep/2013-02/msg00102.html
xorg-macros doesn't install pkg-config
cp *pc ../prefix/lib/pkgconfig/
Mesa: no package glproto, x11 xorg-macros, etc.
Build mesa with scons www.mesa3d.org/install.html
scons platform=windows toolchain=crossmingw machine=x86_64 mesagdi libgl-gdi
gst-plugins-base: error: unknown conversion type character 'l' in format - scaning long long
patch -p0 < gst-plugins-base.patch
patch -p0 < gst-plugins-bad.patch
If you get "cannot find -ldl" remove -ldl from the offending file
gstreamer-plugins-ugly:
Add --disable-twolame to ./configure options
test
Update .wine/system.reg
"GSTREAMER_SDK_ROOT_X86_64"="C:\\gst64"
"GST_PLUGIN_PATH_1_0"="%GSTREAMER_SDK_ROOT_X86_64%\\lib\\gstreamer-1.0"
"PATH"=str(2):"C:\\Python27\\;C:\\Python27\\Scripts;C:\\windows\\system32;C:\\windows;C:\\windows\
\system32\\wbem;%GTKDIR%\\bin;%GSTREAMER_SDK_ROOT_X86_64%\\bin;/usr/x86_64-w64-mingw32/sys-root/mi ngw/bin"
Try it out.
cd $HOME/.wine/drive_c/gst64/bin
wine gst-inspect-1.0.exe
FAQ
Q. How do you know where to download source packages from?
A. Get "rinfo" for Fedora Linux. Append to .bashrc to make it permanent.
alias rinfo='rpm -qi --nodigest --nosignature'
Usage: rinfo [package name]
References:
stackoverflow.com/questions/26042077/cross-compiling-python-setup
stackoverflow.com/questions/5139403/whats-the-difference-of-configure-option-build-host-and-target
www.gaia-gis.it/gaia-sins/mingw64_how_to.html#env
gstreamer.freedesktop.org/wiki/GStreamer_Cross_Compile_With_MinGW_In_Chroot_Environment
gstreamer.freedesktop.org/data/doc/gstreamer/head/faq/html/chapter-getting.html
fedoraproject.org/wiki/Packaging