MythTV on Windows

From MythTV Official Wiki
Revision as of 21:09, 26 December 2007 by Zack (talk | contribs) (Problems others have encountered)

Jump to: navigation, search

Summary

A Windows port of MythTV is in-the-works, using MinGW as the build platform, and MS Direct3D as the display layer. The frontend compiles, and most basic functionality works, but it crashes regularly. The patches are currently working their way into SVN, so check the -dev list, and Trac for the current state. Once the frontend is reliable, we can start to see about getting the changes necessary to get MythBackend to run.

Background & Caveats

Cygwin was previously a limiting factor as it introduced a dependency on cygwin1.dll. We have moved to MinGW, which compiles all the necessary functions statically, rather than linked in through a separate dll.

Please start by reading this link: http://mythtv.org/pipermail/mythtv-dev/2007-December/058662.html

the Trac reference is here: http://svn.mythtv.org/trac/ticket/4270

MinGW/GCC doesn't seem to work well under Vista 64 bit (maybe even 32 bit too). Try compiling on an 2000/XP box instead.

HOWTO - A WORK IN PROGRESS

1 - Install MinGW - download the "Automated MinGW Installer".

 homepage:
 http://www.mingw.org/
 When installing, be sure to install g++ in addition to the default gcc.   Typlical install path is c:\MinGW, but it shouldn't matter.
 direct download (almost): 
 http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=240780&release_id=529741
 more info: http://www.mingw.org/download.shtml 


2 - Install "MSYS base system" current release "MSYS-1.0.10.exe"

 download: 
 http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=24963
 more info: http://www.mingw.org/
 During the installation leave destination folder as C:\Msys\1.0 
 When instructed by msys (in a DOS window) enter the path where you installed MinGW.

You might find that you get an error in "sync with child / child state waiting for longjump" or "Couldn't reserve space for cygwin's heap" when in the post-instllation (DOS window). This error definitely occurs with Vista 64 bit edition. The solution that I found to solve the problem, is to go to the MSYS Technology Preview download page and select the MSYS-1.0.11-20071204.tar.bz2 file:

 http://downloads.sourceforge.net/mingw/MSYS-1.0.11-20071204.tar.bz2?modtime=1196807934&big_mirror=1
 Then, unpack the files on your existing MSYS directory (default C:\MSys\1.0). It should 
 overwrite these files: 
 bin/msys-1.0.dll 
 bin/mount.exe 
 bin/ps.exe 

3 - download and extract MSYS additional component/s: into your MSYS instalation :

 3a:  bash -  bash-3.1-MSYS-1.0.11-1.tar.bz2  
 direct download:
 http://downloads.sourceforge.net/mingw/bash-3.1-MSYS-1.0.11-1.tar.bz2?modtime=1195140582&big_mirror=1
 Extract to C:\MSys\1.0 and overwrite any existing files
 3b:  zlib
 direct download:
 http://downloads.sourceforge.net/mingw/zlib-1.2.3-MSYS-1.0.11.tar.bz2?modtime=1190248364&big_mirror=1
 Extract to C:\MSys\1.0
 Not sure what is going on, but I found that when running .configure in taglib it could not find zlib unless I copied it into MinGW -- Simon Kenyon
 3c: 'pr' command
 the coreutils package (part of MSYS?) contains the 'pr' command.
 direct download:
 http://downloads.sourceforge.net/mingw/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2?modtime=1188741011&big_mirror=1
 Extract to C:\MSys\1.0


4 - optionally update the GCC version.

Andrei used GCC 4.2.2 from here (and has had success!):

 http://www.tdragon.net/recentgcc/
 It's a drop-in replacement for MinGW gcc, and it comes with pthread library.
 direct downloads:
 http://downloads.sourceforge.net/tdm-gcc/gcc-4.2.2-tdm-1-core-1.7z
 http://downloads.sourceforge.net/tdm-gcc/gcc-4.2.2-tdm-1-g++-1.7z
 (requires 7-zip to extract: see http://www.7-zip.org/download.html)

Note: The notes on the above page indicate that the Technology Preview from the main MinGW page might be better.

Buzz will be trying to build with the default mingw (3.4.5) or if necessary the technology preview of 4.2.1.

 So far, 4.2.1 has NOT been been needed, but he's not finished the build process yet. Here's the links to it anyway.
 4.2.1 preview:
 http://downloads.sourceforge.net/mingw/gcc-core-4.2.1-sjlj-2.tar.gz?modtime=1187065794&big_mirror=1
 After downloading extract to C:\MinGW and overwrite any files there
 http://downloads.sourceforge.net/mingw/gcc-g%2B%2B-4.2.1-sjlj-2.tar.gz?modtime=1187065795&big_mirror=1
 After downloading extract to C:\MinGW and overwrite any files there
 To make GCC 4.2.1 the default version, do the following commands in C:\MinGW\bin:
 copy gcc-sjlj.exe gcc.exe
 copy gccbug-sjlj.exe gccbug.exe
 copy mingw32-gcc-sjlj.exe mingw32-gcc.exe
 copy g++-sjlj.exe g++.exe
 copy mingw32-g++-sjlj.exe mingw-g++.exe
 http://downloads.sourceforge.net/mingw/libgcc_sjlj_1.dll.gz?modtime=1187162717&big_mirror=1
 After downloading extract to ???


5 - install tortoiseSVN for GUI access to subversion.

 http://tortoisesvn.tigris.org/
 direct download:
 http://downloads.sourceforge.net/tortoisesvn/TortoiseSVN-1.4.5.10425-win32-svn-1.4.5.msi?download

6 - get the latest copy of the mythtv source code :

 a - make a folder c:\mythtv\
 b - right-click on the mythtv folder you just created and choose "SVN Checkout..."
 c - enter the string "http://svn.mythtv.org/svn/trunk/" (without the quotes) into the tortoiseSVN window, and click OK. 
 c - wait for very large download to finish (roughly 127MB)

7 - enter the msys environment by running c:\msys\1.0\msys.bat

 Looks like unix doesn't it!.
 HINT: type 'mount' to see how msys lays out it's folders.

8 - Don't forget to export QT environment variables

   export QTDIR=/--path to qt location--/qt-3.3.x-p8
   export QMAKESPEC=$QTDIR/mkspecs/win32-g++
   export LD_LIBRARY_PATH=$QTDIR/lib

9 - download and compile all the libs for all the libraries listed below in the "libs" section. a lot of work

Hopefully we'll be able to make all these library dependencies quicker, and just supply pre-built versions to download, for those libraries that are stable.?

10 - try to compile mythv and if successful the plugins too!

 cd /c/mythtv
 cd mythtv
 ./configure --prefix=/usr --disable-dbox2 --disable-hdhomerun \
 --disable-dvb --disable-ivtv --disable-iptv --disable-joystick-menu \
 --disable-xvmc-vld --disable-x11 --disable-xvmc --enable-directx \
 --enable-memalign-hack --cpu=k8 --compile-type=debug
 make 
 make install
 cd ..


 cd mythplugins
 ./configure --prefix=/usr --disable-mythgallery --disable-mythmusic --disable-mytharchive --disable-mythbrowser --disable-mythflix --disable-mythgame --disable-mythnews --disable-mythphone --disable-mythzoneminder --disable-mythweb --enable-aac --enable-libvisual --enable-fftw --compile-type=debug --disable-x11 --disable-v4l --disable-audio-oss --disable-audio-alsa --disable-ivtv --enable-directx
 make
 make install
 cd ..

Binary Dependencies / Libs

MySQL:

 download "Windows Essentials (x86)" from here:
 http://dev.mysql.com/downloads/mysql/5.0.html#win32
 almost direct download:
 http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-essential-5.0.45-win32.msi/from/pick#mirrors
 During installation, click the Custom setup type
 Ensure that C Include Files / Lib Files are installed onto the local drive.

There is a lot more to it than this. MySQL does not come with the correct libraries necessary to build qt. When I have worked out what to do I will update the wiki. See:

http://wiki.qtcentre.org/index.php?title=Building_the_QMYSQL_plugin_on_Windows_using_mingw

Source Libs

For all the libs below, except when noted otherwise, use tar xvzf xxxx.tar.gz, cd xxxxx, ./configure --prefix=/usr && make && make install to build and install them, there's nothing special that needs to be done.

TIP: For those unfamiliar with libraries, using the shortname (eg 'ogg') normally refers to a download/library called 'libogg.xxxxx.tar.gz', or similar.

 freetype: 
 http://savannah.nongnu.org/projects/freetype
 direct download:
 http://download.savannah.nongnu.org/releases/freetype/freetype-2.3.5.tar.gz
 lame: download version 3.97 from sourceforge
 http://lame.sourceforge.net/index.php
 direct download (almost):
 http://sourceforge.net/project/showfiles.php?group_id=290&package_id=309&release_id=450142
 mad: version 0.15.1b from sourceforge
 http://www.underbit.com/products/mad/
 direct download (almost):
 http://sourceforge.net/project/showfiles.php?group_id=12349&package_id=86999&release_id=217880
 
 taglib: version 1.4 from freshmeat:
 homepage:
 http://freshmeat.net/projects/taglib
 direct download:
 http://developer.kde.org/~wheeler/files/src/taglib-1.4.tar.gz
 TIP: Buzz found that 'make install' failed until all the Makefiles were tweaked:
   change any of these:
     INSTALL = C:/msys/1.0/bin/install -c -p
     INSTALL = ../C:/msys/1.0/bin/install -c -p
     INSTALL = ../../C:/msys/1.0/bin/install -c -p
   into:
     INSTALL = /bin/install -c -p
 ogg version 1.1.3 and
 vorbis version 1.2.0 from xiph
 http://xiph.org/downloads/
 You must compile and install three components and in the following order:
   libao
   libogg
   libvorbis
 direct downloads:
 http://downloads.xiph.org/releases/ao/libao-0.8.8.tar.gz
 http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
 http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.0.tar.gz
 for vorbis, use "./configure --prefix=/usr --disable-shared"
 (or find how to resolve undefined references to libogg, this shouldn't be too hard).
 flac 1.2.1
 http://flac.sourceforge.net/
 direct download (almost):
 http://sourceforge.net/project/showfiles.php?group_id=13478&package_id=12677&release_id=539981
 TIP: flac version 1.2.1 may not compile.
   Buzz found that to add:
    #define SIZE_T_MAX UINT_MAX  
   to the end of the /mingw/include/limits.h file got it build (after a 'make clean').
   ( see this link: see http://forum.zdoom.org/viewtopic.php?f=7&t=15452&p=310197 ) 
 libpthread
 http://www.gnunet.org/hacking_win32_build.php3 has a good summary and pre-compiled libraries
 directX header files
 You will need a copy of the Microsoft DirectX SDK for dsound.h, d3dtypes.h and ddraw.h. To get the needed DirectX header files from the Microsoft DirectX SDK:
   * Go to http://msdn.microsoft.com/downloads/
   * Select the DirectX SDK (November 2007)
   * Click on the Download link on the right
   * This is a 427 MB file!
   * Run the downloaded program
   * Untick "When done unzipping open Setup.exe" - there is no need to install the SDK
   * click Unzip to extract it to C:\mssdk\temp
   * Click "OK" and "Close" when the program finishes extracting the files
   * Copy the following files from SDK's include directory (C:\mssdk\temp\Include) ddraw.h dinput.h and dsound.h to the to the mingw include directory (C:\MinGW\Include) 
 There is a d3d9types.h. Should this be renamed to d3dtypes.h? Also the list at the start of the header file section is different to the list at the end! (I merged them to be safe) -- Simon Kenyon

Optional libraries: For "MythGallery":

 tiff 
 http://www.libtiff.org/
 direct download:
 ftp://ftp.remotesensing.org/pub/libtiff/tiff-3.8.2.tar.gz
 exif
 http://libexif.sourceforge.net/
 direct download:
 https://sourceforge.net/project/showfiles.php?group_id=12272&package_id=38136&release_id=515385

for "MythMusic":

 libvisual
 http://sourceforge.net/projects/libvisual/
 direct download:
 http://downloads.sourceforge.net/libvisual/libvisual-0.4.0.tar.gz?modtime=1142891522&big_mirror=0
 SDL
 http://www.libsdl.org/
 direct download: 
 http://www.libsdl.org/release/SDL-1.2.12.tar.gz
 Buzz is currently unable to build SDL because of this error:
 /bin/sh ./libtool --mode=link gcc -o build/libSDL.la build/SDL.lo build/SDL_error.lo build/SDL_fatal.lo 
 build/SDL_audio.lo build/SDL_audiocvt.lo build/SDL_audiodev.lo build/SDL_mixer.lo build/SDL_mixer_MMX.lo 
 build/SDL_mixer_MMX_VC.lo build/SDL_mixer_m68k.lo build/SDL_wave.lo build/SDL_cdrom.lo build/SDL_cpuinfo.lo 
 build/SDL_active.lo build/SDL_events.lo build/SDL_expose.lo build/SDL_keyboard.lo build/SDL_mouse.lo 
 build/SDL_quit.lo build/SDL_resize.lo build/SDL_rwops.lo build/SDL_getenv.lo build/SDL_iconv.lo   
 build/SDL_malloc.lo build/SDL_qsort.lo build/SDL_stdlib.lo build/SDL_string.lo build/SDL_thread.lo 
 build/SDL_timer.lo build/SDL_RLEaccel.lo build/SDL_blit.lo build/SDL_blit_0.lo build/SDL_blit_1.lo 
 build/SDL_blit_A.lo build/SDL_blit_N.lo build/SDL_bmp.lo build/SDL_cursor.lo build/SDL_gamma.lo 
 build/SDL_pixels.lo build/SDL_stretch.lo build/SDL_surface.lo build/SDL_video.lo build/SDL_yuv.lo   
 build/SDL_yuv_mmx.lo build/SDL_yuv_sw.lo build/SDL_joystick.lo build/SDL_nullevents.lo build/SDL_nullmouse.lo 
 build/SDL_nullvideo.lo build/SDL_diskaudio.lo build/SDL_dummyaudio.lo build/SDL_sysevents.lo 
 build/SDL_sysmouse.lo build/SDL_syswm.lo build/SDL_wingl.lo build/SDL_dibevents.lo build/SDL_dibvideo.lo 
 build/SDL_dibaudio.lo build/SDL_mmjoystick.lo build/SDL_syscdrom.lo build/SDL_sysmutex.lo build/SDL_syssem.lo 
 build/SDL_systhread.lo build/SDL_syscond.lo build/SDL_systimer.lo build/SDL_sysloadso.lo build/version.o  -lm 
 -luser32 -lgdi32 -lwinmm -no-undefined -rpath /usr/lib -release 1.2 -version-info 11:1:11
 libtool: link: cannot build libtool library `build/libSDL.la' from non-libtool objects on this host: 
 build/version.o
 make: *** [build/libSDL.la] Error 1


 fftw 
 http://www.fftw.org/
 direct download:
 http://www.fftw.org/fftw-3.1.2.tar.gz
 TIP:(you might want to configure with "./configure --prefix=/usr --with-gcc-arch=k8")
 TIP: there are also MinGW tips here: http://www.fftw.org/install/windows.html

QT

QT deserves its own section on this page, because it wasn't trivial to make QMake work, and because it had a couple of bugs, one of them critical, leading to deadlocks in MythFrontend.

First follow the instructions to download (don't build just yet) QT from this page:

 http://qtwin.sourceforge.net/qt3-win32/compile-mingw.php

direct download (almost):

 http://downloads.sourceforge.net/qtwin/qt-3.3.x-p8.tar.bz2?modtime=1178810003&big_mirror=0

Then, apply the qt patch from here: http://svn.mythtv.org/trac/ticket/4270

 download it to the qt-3.3.x-p8 sources folder 
 gunzip qt.patch.gz
 patch -p1 < qt.patch

The patch fixes one critical bug, fixes one issue preventing it from working properly with bash, implements "install" in makefiles, and reduces number of compiler warnings during MythTV compilation. Unfortunately, this breaks QT build scripts, but it still allows to build the qt-mt3.dll properly.

Now build QT using the instructions from the download page (copied here in brief):

TIP: building QT is NOT done in the msys environment, it's done in a DOS(cmd.exe) box!


Compiling Qt with command line tools

Open a cmd shell (make sure you haven't msys or cygwin in your PATH! )

Setup Qt environment :

 c:\source> set QTDIR=< qt3 source root >
 c:\source> set MINGW=< MinGW installation root >
 c:\source> set PATH=%QTDIR%\bin;%MINGW%\bin;%PATH%
 c:\source> set QMAKESPEC=win32-g++

Configure and build the source: The script first creates link_includes.exe and configure.exe which are needed for bootstrap the build process. link_includes copies all relevant Qt headers into the include-directory. configure.exe is the replacement for the ./configure-script unter Unix/Linux. After that, qmake.exe is build and the compilation gets started.

 c:\source> cd < qt3 source root >
 c:\source\qt-3> configure.bat -thread -plugin-sql-mysql -opengl -no-sql-sqlite [-fast] [-verbose]
 configure knows some of the parameters of the x11 release configure script like -fast or -verbose.
 For a full list see bin\configure.exe -help.

This should build the whole Qt release. If it breaks you can restart compiling with:

 c:\source\qt-3> mingw32-make [< target >]
 for a list of all available targets see the toplevel Makefile

The easiest way to get QT to work in a command line is to rename the sh.exe which MINGW and MSYS use. Rename mingw\bin\sh.exe and msys\1.0\bin\sh.exe before seting up QT. Once the libaries are compiled you can rename them back.

During debugging, I found one more bug in QT: QSocketNotifier never generates "signals" for listening sockets, which effectively prevents anything that listens incoming connections (mythbackend and possibly UPNP code in mythfrontend too) from accepting them.

Problems others have encountered

Problem:

 Broken shell detected.  Trying alternatives.
 Trying shell bash 
 ./configure: line 245: pr: command not found

Solution:

 The 'pr' command is missing from your mingw install, installing "additional components" into your MSYS install will fix 
 this (see step 3 above for hints).  From memory, I think the additional component is "bash-utils".??

Problem:

  I have compiled all of the dependencies and such but when I go to run the configure script for myth I get:
 "ERROR! You must have FreeType installed to compile MythTV."

Solution:

 Have you installed freetype with "make install"? Do you have  libfreetype-6.dll in your mingw bin directory and freetype2/freetype 
 in your include directory? (I have done all of the above and this still does not work for me - Jay)

Problem:

  QT compile failed it could not find mysql.h

Solution:

 In mysql.h, there are lines that start with something like "MinGW supports unix API" - make sure you comment or remove them or you 
 will be getting segfaults because the functions will be declared as stdcall when they are cdecl (or something close to it) - Andrei

Problem:

 there are some issues with the mysql package in that there is no supplied libmysql.a

Solution:

 You don't need libmysql.a, gcc can link directly against libmysql.dll - Simon Kenyon (Actually, I asked the question; Andre provided the answer)

Problem:

 QT issue: Are you saying that i don't need to do any of this reimp/dlltool nonsense?

Comments/Solution:

 Yes, that's what I'm saying. I had more problems with the import libraries than without them. One of the changes I made 
 to qmake's mkspec is to stop generating them. - Andrei  ( I think Andrei was refering to the QT patch on Ticket #4270 ?? - Buzz)

Problem:

 I'm getting the following error
 g++ -c -mthreads -w -O2 -fexceptions -frtti -DQT_SHARED -DQT_THREAD_SUPPORT -DQT
 _ACCESSIBILITY_SUPPORT -DQT_TABLET_SUPPORT -DQT_NO_DEBUG -DUNICODE -DQT_MAKEDLL
 -DQT_THREAD_SUPPORT -DQT_NO_CUPS -DQT_NO_NIS -DQT_NO_STYLE_MAC -DQT_NO_STYLE_AQU
 A -DQT_NO_STYLE_WINDOWSXP -DQT_NO_STYLE_POCKETPC -DQT_DLL -DQT_MAKEDLL -I"tmp" -
 I"3rdparty/libmng" -I"3rdparty/libjpeg" -I"3rdparty/libpng" -I"3rdparty/zlib" -I
 "C:\msys\1.0\qt/include" -I"tmp/moc/release-shared-mt/" -I"C:/msys/1.0/qt/mkspec
 s/win32-g++" -o tmp/obj/release-shared-mt/qsound_win.o kernel/qsound_win.cpp
 kernel/qsound_win.cpp:194:26: error: qsound_win.moc: No such file or directory
 mingw32-make[2]: *** [tmp/obj/release-shared-mt/qsound_win.o] Error 1
 mingw32-make[2]: Leaving directory `C:/msys/1.0/qt/src'
 mingw32-make[1]: *** [sub-src] Error 2
 mingw32-make[1]: Leaving directory `C:/msys/1.0/qt'
 mingw32-make: *** [init] Error 2
 C:\msys\1.0\qt>
 Anyone know what to do to fix this?
 -- Simon Kenyon

Comments/Solution:

 I'm not sure why this happens as I had one install of msys work fine and then same error as you.

In the end I had to cd into /msys/qt-3/src and edit the Makefile and add

-I"c:/msys/qt-3/src/tmp/moc/release-shared-mt" 

on the INCPATH line (I have the qt-3 src at c:/msys).