Difference between revisions of "Build from Source"

From MythTV Official Wiki
Jump to: navigation, search
(Prerequisites: fix dev-libfame not found)
m (Dependencies: add dh-systemd as has changed for 0.28)
(41 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
{{User_Manual_TOC}}
 
{{User_Manual_TOC}}
 
+
{{UpToDate 0.28}}
This page is up-to-date to MythTV version 0.21, the current release is {{CurrentRelease}}
 
  
 
==Introduction==
 
==Introduction==
 +
For most people, it will be far easier to install a pre-built package for MythTV rather than building from source. Reasons for building from source include:
 +
*There is no pre-built package for your Linux distribution.
 +
*The pre-built package for your distribution is out of date.
 +
*You want to run a pre-release version of the software.
 +
*Users choose to test/write patches.
  
There are different ways to get Mythtv installed on your system: 
+
If you have already installed a pre-built package and you have a need to try out a source code change, it would be preferable to use your distribution's build process to build a version that is compatible with the already installed version. There are differences in the placement of files between the downloaded packages and the code you build yourself.
 
 
# From source;
 
# Using apt-get;
 
# Using a MythTV Linux distribution (e.g. MythBuntu, MythDora, etc.) [[MythTV distros |more info]].
 
 
 
In this guide we will discuss how to install from source.
 
 
 
This guide is will allow you to build the latest version of MythTV on Ubuntu and Fedora.
 
 
 
== Prerequisites ==
 
 
 
First install required packages (Version: 0.27):
 
 
 
<code><pre>
 
sudo apt-get install build-essential liblircclient-dev libasound2-dev libdts-dev libdvdnav-dev \
 
libxv-dev libxxf86vm-dev transcode libmp3lame-dev subversion qt4-dev-tools libqt4-dev libsamplerate0 \
 
libxvidcore4 liba52-0.7.4-dev libcdio-dev msttcorefonts libasound2-doc libmad0-dev \
 
libid3tag0-dev libvorbis-dev libflac-dev libcdaudio-dev libcdparanoia0-dev fftw3-dev libfaad-dev \
 
libsmpeg-dev libmp4v2-dev libtag1-dev mysql-server libvisual-0.4-dev libexif-dev libxvmc-dev \
 
libxinerama-dev uuid-dev libicu-dev
 
</pre></code>
 
 
 
Note: Version 0.24 requires also '''libfreetype6-dev'''; not required but advised: '''yasm''', '''ccache'''.
 
 
 
Note: Version 0.21 and earlier use QT3 instad of QT4, so you need: '''libqt3-mt-dev''' and '''libqt3-mt-mysql'''.
 
  
 +
This guide shows how to build from source code downloaded from github.
  
To install css support use:
+
==Raspberry Pi==
<code><pre>
+
Starting from version 0.28 It is possible to build and run MythTV frontend on a Raspberry Pi 2 or Raspberry Pi 3. Since the Raspberry Pi has limited resources there are some steps you can take to ensure a successful build.
/usr/share/doc/libdvdread3/install-css.sh
+
{| class="mw-collapsible mw-collapsed wikitable"
</pre></code>
+
!| Setting up a Raspberry Pi for building MythTV
or on newer distributions:
+
|-
<code><pre>
+
|MythTV can be built on any linux variant that runs on Raspberry Pi. That includes Raspbian, Ubuntu Mate, Arch Linux. Before attempting to build you should take these steps.
/usr/share/doc/libdvdread4/install-css.sh
 
</pre></code>
 
  
If you want mythweb as well - you need
 
<code><pre>
 
sudo apt-get install apache2 php5 libapache2-mod-php5 php5-mysql
 
</pre></code>
 
On some systems (might be already installed on your system) you have to install the following to prevent issues with downloading recordings
 
<code><pre>
 
sudo apt-get install libcpandb-perl
 
</pre></code>
 
If you want VAAPI support you will need libva-dev
 
<code><pre>
 
sudo apt-get install libva-dev
 
</pre></code>
 
  
==Getting and compiling the source code==
+
'''Install the operating system on an external USB hard drive.'''
  
Get the [http://code.mythtv.org/trac latest code] for MythTV. In general, you should probably choose the stable version. If you don't mind if your MythTV system is non-functional or has serious bugs that may prevent proper operation/result in lost recordings or inability to play back recordings, you may try using the unstable, development code. If using unstable, development code, you should follow the [http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-commits mythtv-commits] and [http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev mythtv-dev] mailing lists.
+
Use a hard drive that has its own power supply. If you have an old hard drive around that you no longer use you can buy a USB enclosure for it. You need a hard drive of 50 GB or more.  
  
Then, simply go in each directory and configure and build each component:
+
These steps can be done on the Raspberry Pi itself but are easier if done from an desktop computer running Linux.  
<code><pre>
 
./configure --enable-proc-opt
 
make
 
make install
 
</pre></code>
 
  
Note that adding any other configure arguments (with the possible exception of --prefix) to the main MythTV configure command is almost definitely a bad idea and shouldn't be required.
+
* Install your Raspberry Pi operating system on an SD card as normal. If you are going to use the Raspberry Pi to prepare the hard drive you will need to prepare a second SD card. Make sure your SD cards boot correctly into the operating system.
 +
* Partition your hard drive. Create an ext4 partition of at least 50 GB for your operating system. I recommend using gparted. Format it as ext4 (gparted can do that for you).
 +
* Copy your SD card contents to the new hard drive partition. If you are using the raspberry pi to do this do not copy the SD card from which you are booted. You will need an SD card reader plugged into a USB port to read the SD card that you are copying from. Use ''lsblk'' to determine the device names. If you are running a Graphical environment it may automatically mount the devices. Otherwise mount them in an appropriate place. On the SD card you are copying from use the second partition (e.g. /dev/sda2).
 +
<pre>sudo cp -av /source/directory/* /dest/directory/</pre>
 +
* Edit the /boot/cmdline.txt file on the SD card you are copying from. Change the parameter ''root=/dev/mmcblk0p2'' to ''root=/dev/sda1''. If you are not using the first partition on the hard drive change sda1 to the correct partition.
 +
* Edit the /etc/fstab file on the hard drive. Find the line for the root mount. Change the device name at the beginning of the line from /dev/mmcblk0p2 to /dev/sda1, or the correct hard drive partition.
 +
* Shut down your raspberry pi, insert the SD card you were copying from, and plug in the external hard drive. Make sure you do not have another drive or USB Card reader plugged in. The raspberry pi will now boot with the hard drive as root partition.
  
For mythplugins, if you don't want some modules you might want to disable them (run "./configure --help" in each directory to see the options you can set for the build).
 
For example:
 
<code><pre>
 
./configure --disable-mythgame --disable-mythnetflix
 
make
 
make install
 
</pre></code>
 
  
Note: If you want to be able to easily uninstall later, for example to update to new set of fixes, use "checkinstall" rather than "make install". "checkinstall" keeps track of all files installed by a "make install" or equivalent, creates a Slackware, RPM, or Debian package with those files, and adds it to the installed packages database, allowing for easy package removal or distribution. "checkinstall" will prompt for a package description, and then you must supply a version number by following the prompts.
+
'''Increase swap space'''
<code><pre>
 
./configure
 
make
 
checkinstall
 
</pre></code>
 
  
== Post-install tasks  ==
+
On your hard drive based system, run the following commands.
=== Creating the mythtv user ===
 
to run MythTV as its own user I created one (so the backend doesnt run as root)
 
<code><pre>
 
sudo useradd mythtv
 
</pre></code>
 
 
 
=== MythTV database setup ===
 
 
 
You have to create a file for mythtv for database connections <code>~mythtv/.mythtv/mysql.txt</code>
 
{{Code box|~mythtv/.mythtv/mysql.txt|<pre>
 
DBHostName=localhost
 
 
 
# By default, Myth tries to ping the DB host to see if it exists.
 
# If your DB host or network doesn't accept pings, set this to no:
 
#
 
DBHostPing=no
 
 
 
DBHostName=localhost
 
DBUserName=mythtv
 
DBName=mythconverg
 
DBPassword=mythtv
 
 
 
# Set the following if you want to use something other than this
 
# machine's real hostname for identifying settings in the database.
 
# This is useful if your hostname changes often, as otherwise you
 
# will need to reconfigure mythtv (or futz with the DB) every time.
 
# TWO HOSTS MUST NOT USE THE SAME VALUE
 
#
 
LocalHostName=MYCOOLMYTHTVHOST
 
 
 
# If you want your frontend to be able to wake your MySQL server
 
# using WakeOnLan, have a look at the following settings:
 
#
 
#
 
# The time the frontend waits (in seconds) between reconnect tries.
 
# This should be the rough time your MySQL server needs for startup
 
#
 
#WOLsqlReconnectWaitTime=0
 
#
 
#
 
# This is the number of retries to wake the MySQL server
 
# until the frontend gives up
 
#
 
#WOLsqlConnectRetry=5
 
#
 
#
 
# This is the command executed to wake your MySQL server.
 
#
 
#WOLsqlCommand=echo 'WOLsqlServerCommand not set'
 
 
 
</pre>}}
 
 
 
Then you have to create a database and let the user set above access it
 
 
<pre>
 
<pre>
mysql -u root -p
+
sudo apt-get install dphys-swapfile
create database mythconverg;
+
sudo dphys-swapfile swapoff
create user 'mythtv'@'%' identified by 'mythtv';
+
sudo dphys-swapfile uninstall
create user 'mythtv'@'localhost' identified by 'mythtv';
 
set password for 'mythtv'@'%' = password('mythtv');
 
set password for 'mythtv'@'localhost' = password('mythtv');
 
connect mythconverg;
 
grant all privileges on *.* to 'mythtv'@'%' with grant option;
 
grant all privileges on *.* to 'mythtv'@'localhost' with grant option;
 
flush privileges;
 
exit;
 
 
</pre>
 
</pre>
 +
edit the file /etc/dphys-swapfile and set CONF_SWAPSIZE=2048
 +
<pre>
 +
sudo dphys-swapfile setup
 +
sudo dphys-swapfile swapon
 +
</pre>
 +
This should give you 2GB swap space. To check it run ''top''. You should see ''KiB Swap:  2097148 total,''.
  
Run <code>mythbackend</code> to test. This will automatically upgrade your previous mythconverg database schema to the latest version:
 
<pre>mythbackend</pre>
 
If mythbackend is running OK, test mythfrontend:
 
<pre>mythfrontend</pre>
 
  
=== Running MythTV on start ===
+
'''Reduce GPU memory'''
I use a slightly modified script from mythbuntu for that. Just copy the content to <code>/etc/init.d/mythtv-backend</code> - chmod it with <code>sudo chmod 755 /etc/init.d/mythtv-backend</code>
 
  
To start every time you still have to add it to the rc:
+
Edit /boot/config.txt and set to following
<code>update-rc.d mythtv-backend defaults</code>
+
<pre>gpu_mem=128</pre>
 +
In my experience this is sufficient for the video that is supported by MythTV. If not you can increase it when you are no doing builds.
  
Also create a log directory for mythtv:
 
<code><pre>
 
sudo mkdir /var/log/mythtv
 
sudo chown mythtv:mythtv /var/log/mythtv
 
</pre></code>
 
  
{{Code box|/etc/init.d/mythtv-backend|<pre>
+
'''Setup ccache'''
#! /bin/sh
 
### BEGIN INIT INFO
 
# Provides:          mythtv-backend
 
# Required-Start:    $local_fs $remote_fs $network
 
# Required-Stop:    $local_fs
 
# Default-Start:    2 3 4 5
 
# Default-Stop:      0 1 6
 
# Short-Description: Start/Stop the MythTV server.
 
### END INIT INFO
 
  
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
After installing the prerequisites make sure there is enough ccache as follows
DAEMON=/usr/local/bin/mythbackend
+
<pre>ccache -M 5G -F 0</pre>
NAME="mythbackend"
 
DESC="MythTV server"
 
  
test -x $DAEMON || exit 0
+
With all of these steps in place, the first build of MythTV will take around 2 hours on a Raspberry Pi 2. Subsequent builds can take as little as 2 minutes. With ccache, even a full rebuild can complete in 10 minutes, because it caches the compiler results and if the source does not change it re-uses them.
 +
|}
  
. /lib/lsb/init-functions
+
== Dependencies ==
 +
One of the most difficult parts of building the code is getting the correct dependencies installed first. The syntax for installing these will vary from one distribution to another, and package names may also vary between distributions.
  
set -e
+
=== Installing Build Dependencies with Ansible ===
 +
Mythtv now has Ansible playbooks to set up build dependencies. These support many Linux variants and will easily install your build dependencies. Follow the following steps to install build dependencies.
 +
* Install git using your distribution package system.
 +
* Follow steps described at https://github.com/MythTV/ansible. For MythTV version 0.28 onwards, use the option "For a normal development system running Qt5". For earlier versions use "For a normal development system running Qt4". All of the commands listed on that page must be run as root or with sudo. Note that 0.27 can run with either QT4 or QT5, and the choice will depend on what is available with your release of Linux.
  
prime_firewire()
+
=== Installing Build Dependencies without Ansible ===
{
+
It is recommended to use Ansible, because that will be kept up to date. Alternatively, to install the dependencies manually, follow these instructions.
    if [ "$ENABLE_FIREWIRE" = "TRUE" ]; then
 
        log_daemon_msg "Priming Firewire "
 
        su - $USER -c "/usr/bin/mythprime"
 
        log_end_msg $?
 
    fi
 
}
 
  
USER=mythtv
+
{| class="mw-collapsible mw-collapsed wikitable"
USER_HOME=$(grep ^$USER /etc/passwd | awk -F : '{print $6}')
+
!colspan="2"| Build Dependencies for version 0.27
RUNDIR=/var/run/mythtv
+
|-
ARGS="--daemon --logpath /var/log/mythtv --pidfile $RUNDIR/$NAME.pid"
+
|style="width: 15%;"| All Environments
EXTRA_ARGS=""
+
|style="width: 85%;"|<code><nowiki>
NICE=0
+
build-essential ccache yasm libqt4-dev libqtwebkit-dev libqt4-opengl-dev po-debconf texi2html  linux-kernel-headers libdvdnav-dev libfreetype6-dev libavc1394-dev libiec61883-dev liblircclient-dev libxinerama-dev libxxf86vm-dev libxvmc-dev libxext-dev libimlib2-dev libasound2-dev libmp3lame-dev libvorbis-dev libdts-dev lsb-release libpulse-dev libxrandr-dev libfftw3-dev libva-dev libvdpau-dev libudev-dev libclass-dbi-perl libnet-upnp-perl libio-socket-inet6-perl libdbd-mysql-perl libjson-perl libwww-perl python-oauth python-lxml python-mysqldb python-pycurl python-urlgrabber libgl1-mesa-dev libdvdread-dev fftw-dev libvorbis-dev libflac-dev libmad0-dev libcdaudio-dev libcdio-dev libcdparanoia-dev libsdl1.2-dev libfaad-dev libexif-dev libtiff5-dev libxv-dev libtag1-dev libvisual-0.4-dev libmysqlclient-dev libdate-manip-perl libxml-simple-perl libimage-size-perl libdatetime-format-iso8601-perl libsoap-lite-perl libx264-dev libvpx-dev libavahi-compat-libdnssd-dev libssl-dev libcdio-cdda-dev libcdio-paranoia-dev libxml2-dev libass-dev libcec-dev uuid-dev libxml-xpath-perl libtool-bin
 +
</nowiki></code>
 +
|-
 +
| i386/amd64
 +
| Add this: <code><nowiki> libcrystalhd-dev </nowiki></code>
 +
|-
 +
| debian-wheezy
 +
ubuntu-precise
 +
| replace <code>libtiff5-dev</code> with <code>libtiff4-dev</code> (avoids conflict in libimlib2-dev).
 +
|-
 +
| Notes
 +
|
 +
If you are building a Debian or Ubuntu package using dpkg-buildpackage you will need these additional packages:
 +
<code><nowiki> debhelper quilt dh-python dh-systemd </nowiki></code>
  
if [ -f /etc/default/mythtv-backend ]; then
+
On debian-wheezy and ubuntu-precise replace <code>dh-python</code> with <code>python-central</code> (avoids backports).
  . /etc/default/mythtv-backend
+
|}
fi
+
{| class="mw-collapsible mw-collapsed wikitable"
 +
!colspan="2"| Build Dependencies for version 0.28
 +
|-
 +
|style="width: 15%;"| All Environments
 +
|style="width: 85%;"|<code><nowiki>
 +
build-essential ccache yasm help2man qtdeclarative5-dev libqt5webkit5-dev libqt5opengl5-dev qtscript5-dev qt5-qmake po-debconf linux-kernel-headers libdvdnav-dev libfreetype6-dev libavc1394-dev libiec61883-dev liblircclient-dev libxinerama-dev libxxf86vm-dev libxvmc-dev libxext-dev libimlib2-dev libasound2-dev libmp3lame-dev libvorbis-dev libdts-dev lsb-release libpulse-dev libxrandr-dev libfftw3-dev libva-dev libvdpau-dev libudev-dev libclass-dbi-perl libnet-upnp-perl libio-socket-inet6-perl libdbd-mysql-perl libjson-perl libwww-perl python python-oauth python-lxml python-mysqldb python-pycurl python-urlgrabber libgl1-mesa-dev libdvdread-dev fftw-dev libvorbis-dev libflac-dev libmad0-dev libcdaudio-dev libcdio-dev libcdparanoia-dev libsdl1.2-dev libfaad-dev libexif-dev libtiff5-dev libxv-dev libtag1-dev libvisual-0.4-dev libmysqlclient-dev libdate-manip-perl libxml-simple-perl libimage-size-perl libdatetime-format-iso8601-perl libsoap-lite-perl libx264-dev libvpx-dev libavahi-compat-libdnssd-dev libssl-dev libcdio-cdda-dev libcdio-paranoia-dev libxml2-dev libass-dev libcec-dev libexiv2-dev uuid-dev libxml-xpath-perl git hello libtool-bin
 +
</nowiki></code>
 +
|-
 +
| i386/amd64
 +
| Add this: <code><nowiki> libcrystalhd-dev </nowiki></code>
 +
|-
 +
| debian-wheezy
 +
| replace <code>libtiff5-dev</code> with <code>libtiff4-dev</code> (avoids conflict in libimlib2-dev).
 +
wheezy will require wheezy-backports repository to then automatically pull in qt5
 +
|-
 +
| raspberry pi
 +
| Add this: <code><nowiki> libraspberrypi-dev </nowiki></code>
 +
|-
 +
| Notes
 +
|If you are building a Debian or Ubuntu package using dpkg-buildpackage you will need these additional packages:
 +
<code><nowiki> debhelper quilt dh-python </nowiki></code>
  
ARGS="$ARGS $EXTRA_ARGS"
+
On debian-wheezy replace <code>dh-python</code> with <code>python-central</code> (avoids backports).
 +
|}
 +
=== Run Time Dependencies ===
 +
If you are installing on a different computer from where you built, you will need the run time dependencies. You do not need the full list of build dependencies. Here is a list of runtime dependencies.
 +
{| class="mw-collapsible mw-collapsed wikitable"
 +
! Run Time Dependencies for version 0.27
 +
|-
 +
|<code><nowiki>
 +
mysql-server ntp libicu48 libqt4-sql-mysql
 +
</nowiki></code>
 +
|}
 +
{| class="mw-collapsible mw-collapsed wikitable"
 +
! Run Time Dependencies for version 0.28
 +
|-
 +
|<code><nowiki>
 +
mysql-server-5.6 ntp libicu55 libqt5sql5-mysql mysql-client-5.6
 +
</nowiki></code>
 +
|}
  
mkdir -p $RUNDIR
+
{| class="mw-collapsible mw-collapsed wikitable"
chown -R $USER $RUNDIR
+
!colspan="2"| Run Time Dependencies for MythWeb
 +
|-
 +
|style="width: 25%;"| All Environments
 +
|style="width: 75%;"|<code><nowiki>
 +
apache2 php5 php5-mysql libhttp-date-perl
 +
</nowiki></code>
 +
|-
 +
| Ubuntu Xenial or where php5 is not available
 +
|<code><nowiki>
 +
apache2 php7 php7-mysql libhttp-date-perl
 +
</nowiki></code>
 +
|}
  
unset DISPLAY
+
The package ''mysql-server'' only needs to be installed on one backend, normally the master backend, or it can be installed on a separate database server, although this would be unusual.
unset SESSION_MANAGER
 
  
#create a symbolic link for mysql.txt so it can't be overwritten
+
On systems that do not have ''mysql-server'' (e.g. remote frontends, slave backends), you need to install ''mysql-client'' instead.
mkdir -p $USER_HOME/.mythtv
 
chown -R $USER $USER_HOME/.mythtv
 
if [ ! -e $USER_HOME/.mythtv/mysql.txt ]; then
 
        ln -s /etc/mythtv/mysql.txt $USER_HOME/.mythtv/mysql.txt
 
fi
 
  
case "$1" in
+
Install the build dependencies on your build machine. Install the Run Time dependencies on your MythTV machine (which may be the same as the build machine). If you plan to use MythWeb, install those dependencies on your master backend system.
  start)
+
{| class="wikitable" style="width: 100%;"
        if [ -e $RUNDIR/$NAME.pid ]; then
+
!Distribution||Install Command||Additional packages
                PIDDIR=/proc/$(cat $RUNDIR/$NAME.pid)
+
|-
                if [ -d ${RUNDIR} -a "$(readlink -f ${RUNDIR}/exe)" = "${DAEMON}" ]; then
+
|style="width: 45%;"|Ubuntu, Debian, MythBuntu, other Debian based distributions.
                        log_success_msg "$DESC already started; use restart instead."
+
|style="width: 40%;"|<code>sudo apt-get install </code>''Dependency List''
                        exit 1
+
|style="width: 15%;"|<pre>build-essential</pre>
                else
+
|}
                        log_success_msg "Removing stale PID file $RUNDIR/$NAME"
+
Depending on your distribution, run the install command with the list of packages.
                        rm -f $RUNDIR/$NAME.pid
 
                fi
 
        fi
 
        prime_firewire
 
        log_daemon_msg "Starting $DESC: $NAME "
 
        start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \
 
                --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS
 
        log_end_msg $?
 
        ;;
 
  stop)
 
        log_daemon_msg "Stopping $DESC: $NAME "
 
        start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \
 
                --chuid $USER --exec $DAEMON -- $ARGS
 
        log_end_msg $?
 
        test -e $RUNDIR/$NAME.pid && rm $RUNDIR/$NAME.pid
 
        ;;
 
  restart|force-reload)
 
        log_daemon_msg "Restarting $DESC: $NAME "
 
        start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \
 
                --chuid $USER --exec $DAEMON -- $ARGS
 
        sleep 3
 
        prime_firewire
 
        start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \
 
                --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS
 
    log_end_msg $?
 
        ;;
 
  status)
 
        # We want to maintain backward compatibility with Hardy,
 
        # so we're not going to use status_of_proc()
 
        pidofproc -p $RUNDIR/$NAME.pid $DAEMON >/dev/null && status=0 || status=$?
 
        if [ $status -eq 0 ]; then
 
                log_success_msg "$NAME is running"
 
        else
 
                log_failure_msg "$NAME is not running"
 
        fi
 
        exit $status
 
        ;;
 
  *)
 
        N=/etc/init.d/$NAME
 
        echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
 
        exit 2
 
        ;;
 
esac
 
  
exit 0
+
==Getting and compiling the source code==
</pre>}}
 
  
=== Autostarting the frontend in Xubuntu / Ubuntu ===
+
{| class="wikitable" style="width: 100%;"
 +
!Step||Command to run
 +
|-
 +
|style="width: 30%;"|create a directory
 +
|style="width: 70%;"|<code>cd<br>mkdir ~/build</code>
 +
|-
 +
|clone
 +
|<code>cd ~/build<br>git clone <nowiki>https://github.com/MythTV/mythtv.git</nowiki> mythtv<br>cd mythtv</code>
 +
|-
 +
|Check versions available
 +
|<code>git branch -a</code>
 +
|-
 +
|Choose your version. The current stable released version is {{CurrentFixes}}. We recommend to use that version.
 +
|<code>git checkout fixes/0.28</code>
 +
|-
 +
|If you have previously done a build in this directory, run this if you need a complete rebuild
 +
|<code>git clean -xfd</code>
 +
|}
  
Create a file in <code>~/.config/autostart/mythfrontend.desktop</code>:
+
In general, you should probably choose the stable version. If you don't mind if your MythTV system is non-functional or has serious bugs that may prevent proper operation/result in lost recordings or inability to play back recordings, you may try using the unstable, development code. If using unstable, development code, you should follow the [http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-commits mythtv-commits] and [http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev mythtv-dev] mailing lists.
{{Code box|~/.config/autostart/mythfrontend.desktop|<pre>
 
[Desktop Entry]
 
Encoding=UTF-8
 
Version=0.9.9
 
Type=Application
 
Name=MythTV Frontend
 
Comment=
 
Exec=mythfrontend
 
StartupNotify=false
 
Terminal=false
 
Hidden=false
 
</pre>}}
 
  
=== Mythweb ===
+
===Build and Install MythTV===
For mythweb I just created a symlink to the checked out mythweb in the <code>/var/www</code>:
+
In the ~/build/mythtv/mythtv directory, run the ./configure script. You can see available options by using the --help parameter with configure:
<code><pre>
+
<pre>./configure --help</pre>
sudo ln -s /usr/local/src/mythtv/mythplugins/mythweb /var/www/mythweb
+
By default the build will install mythtv in a directory structure under /usr/local/. Executables will be in /usr/local/bin. You can modify this behavior with the --prefix= parameter. The default prefix is /usr/local.
# make sure data is writeable
 
sudo chown -R www-data /usr/local/src/mythtv/mythplugins/mythweb/data
 
</pre></code>
 
  
you have to enable mod-rewrite
+
Normally you will not need to supply any options to configure, although 0.27 users should add ''--disable-mythlogserver'' ([[Mythlogserver|mythlogserver]]). Run it as follows:<br>
<code><pre>
+
{| class="wikitable" style="width: 100%;"
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
+
!Distribution||Command to run
</pre></code>
+
|-
 +
|style="width: 20%;"|Raspbian,<br>Ubuntu MATE for Raspberry Pi<br>'''Note:''' ''Raspberry pi is only supported with version 0.28 or later''
 +
|style="width: 80%;"|<code>
 +
export  CFLAGS="-I/opt/vc/include -I/opt/vc/include/IL -I/opt/vc/include/interface/vcos/pthreads  -I/opt/vc/include/interface/vmcs_host/linux"<br>
 +
export  CXXFLAGS="-I/opt/vc/include -I/opt/vc/include/IL -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"<br>
 +
export  LDFLAGS="-L/opt/vc/lib"<br>
 +
./configure --compile-type=release --disable-mythlogserver --disable-crystalhd --enable-lirc --enable-audio-alsa --enable-audio-oss --enable-dvb --enable-ivtv --enable-firewire --enable-joystick-menu --with-bindings=perl --enable-ffmpeg-pthreads --enable-pic --perl-config-opts="INSTALLDIRS=vendor" --enable-libvpx --enable-sdl --enable-libmp3lame --enable-libx264 --disable-vdpau --disable-opengl-video --disable-opengl --disable-vaapi
 +
</code>
 +
|-
 +
|Others
 +
|<code>./configure --compile-type=release</code>
 +
|-
 +
|}
 +
If you want to build with debugging info, use <code>--compile-type=profile</code>. There are problems with using debug as the compile type.
  
you also need to have a version of php which has session, mysql, pcre, posix and json support
+
The configure step may identify dependencies that are missing. If so you will need to find them and install them before continuing. Please let us know via an update to this page or make a comment in th discussion page.
  
and copy/edit the apache config
+
If the configure was successful, run the build as follows
 +
<pre>make -j 5</pre>
 +
The -j option is optional but can speed up the make by running multiple processes at the same time. Set the number to 1 higher than the number of cores in your system.<br>
 +
The build may identify missing dependencies. Install them and notify us via a comment in the discussion.<br>
 +
When the build is successful, install this way
 +
<pre>sudo make install</pre>
 +
This will install both backend and frontend software. Install this on all machines, backend or frontend. You will only start the backend on the backend machines. On frontend machines the backend software will exist but will not be used.
 +
===Build and Install Plugins===
 +
Building and installing the plugins is optional. I recommend that new users skip this step. Plugins are not needed for any of the main functionality of MythTV, including watching Videos and watching DVDs. Plugins are for Music, Weather, YouTube, Games, etc.
  
<code><pre>
+
Plugins are only used on the frontend, so if you have a separate backend you need not install them on the backend.
sudo cp mythplugins/mythweb/mythweb.conf.apache /etc/apache2/sites-available/mythweb.conf
 
sudo ln -s /etc/apache2/sites-available/mythweb.conf /etc/apache2/sites-enabled/mythweb.conf
 
</pre></code>
 
  
after that restart and have fun:
+
The plugins build requires that you have first completed a build of mythtv and installed it. It makes use of some of the items set up in the mythtv configure step, and some of the items installed in the install step, so if you have cleaned your mythtv build, the plugins build will not work.
<code><pre>
 
sudo /etc/init.d/apache2 restart
 
</pre></code>
 
  
== Something didn't work? ==
+
In the ~/build/mythtv/mythplugins directory, run the same commands as above for building and installing MythTV. If you only want to build certain plugins, you can disable the others in the ./configure command (check the --help for the syntax for that).
With this you should be able to compile and install mythtv on a new (x)ubuntu box. Most problems come with mythtv setup (config files, database initialization etc.) Please refer to the other wiki pages/documentation for info on that. Before doing that It's best to do some investigation yourself.
+
<pre>./configure
 +
make -j 5
 +
sudo make install</pre>
 +
===Shared-Library requirements for MythTV===
 +
The runtime manager for shared libraries, /lib/ld.so, gets information about the locations and contents of shared libraries from /etc/ld.so.cache, a file created by ldconfig from information in /etc/ld.so.conf. Because MythTV installs shared libraries in /usr/local/lib, that directory needs to be added to the list of directories for ld.so to search when doing runtime linking of programs, if it is not already there. You do this, as root, by editing /etc/ld.so.conf, then running ldconfig.  There are many ways to do this; to determine the way that your distribution is configured, type:
 +
<pre>
 +
cat /etc/ld.so.conf
 +
cat /etc/ld.so.conf.d/*
 +
</pre>
  
The best way to debug problems is to check the output of the backend and frontend tasks:
+
Check if <code>/usr/local/lib</code> is included in the list displayed. If so then no action is needed.
  
To check the backend for error messages:
+
If <code>/usr/local/lib</code> is not already included, then create as root a file under <code>/etc/ld.so.conf.d</code> that contains a line containing
 +
<pre>/usr/local/lib</pre>
  
  tail -f /var/log/mythtv/mythbackend.log
+
Make sure that /etc/ld.so.conf contains a line as follows
 +
<pre>include /etc/ld.so.conf.d/*.conf</pre>
  
To check the frontend for errors, you have two options:
+
To ensure the cache has been updated, run this command:
 +
<pre>sudo /sbin/ldconfig</pre>
  
1) run it from the command line. You can ALT+TAB to see the output in the terminal window while the frontend is running:
+
===Test Setup===
 +
Instead of setting up the shared library cache as described above, if you have customized the location of the libraries using for example ''./configure --prefix=/home/peter/work/mythtv'', you can install and run the backend and frontend in your home directory by setting the path of the lib files as follows:
 +
<pre>
 +
export LD_LIBRARY_PATH=/home/peter/work/mythtv/lib
 +
export PATH="$PATH:/home/peter/work/mythtv/bin"
 +
</pre>
  
  mythfrontend
+
===Install MythWeb===
 +
If you plan to run MythWeb, install it on your master backend server. Install the dependencies, listed above. Check out Mythweb from git:
 +
{| class="wikitable" style="width: 100%;"
 +
!Step||Command to run
 +
|-
 +
|style="width: 30%;"|clone
 +
|style="width: 70%;"|<code>cd ~/build<br><nowiki>git clone https://github.com/MythTV/mythweb.git mythweb</nowiki><br>cd mythweb</code>
 +
|-
 +
|Check versions available
 +
|<code>git branch -a</code>
 +
|-
 +
|Choose your version. The current stable released version is {{CurrentFixes}}. We recommend to use that version.
 +
|<code>git checkout fixes/0.xx</code>
 +
|-
 +
|}
  
2) check the frontend log for error messages:
+
Set up the web application as follows:
  
  tail -f /var/log/mythtv/mythfrontend.log
+
<pre>cd ~/build/mythweb/
 +
sudo cp -r ~/build/mythweb /usr/local/share/mythtv/mythweb
 +
sudo ln -s /usr/local/share/mythtv/mythweb/ /var/www/html/
 +
sudo cp -v /usr/local/share/mythtv/mythweb/mythweb.conf.apache /etc/apache2/sites-available/mythweb.conf
 +
</pre>
 +
Edit file /etc/apache2/sites-available/mythweb.conf using gedit or vi, for example:
 +
<pre>sudo vi /etc/apache2/sites-available/mythweb.conf</pre>
 +
Change the lines containing ''<Directory "/var/www/html/data">'' and ''<Directory "/var/www/html" >'' so that they read ''<Directory "/var/www/html/mythweb/data">'' and ''<Directory "/var/www/html/mythweb" >'', i.e. add the ''mythweb'' subdirectory.
 +
<pre>
 +
sudo a2enmod rewrite
 +
sudo a2ensite mythweb.conf
 +
sudo chown -R www-data:www-data /usr/local/share/mythtv/mythweb/data/
 +
sudo chmod -R g+w /usr/local/share/mythtv/mythweb/data/
 +
</pre>
 +
Restart your apache server as follows to get the changes applied:
 +
<pre>
 +
sudo /etc/init.d/apache2 restart
 +
</pre>
 +
the database and backend must be running for MythWeb to work. At this point you have not yet set up the database or the backend so you cannot try MythWeb. Once those things have been set up and are running, test MythWeb by navigating to <nowiki>http://servername/mythweb</nowiki> where ''servername'' is your master backend server on which mythweb is running. If running from a different system you may have to add ''servername'' plus its ip address to your /etc/hosts file.
  
==System settings==
+
For more advanced and detailed instructions on MythWeb see the file mythweb/INSTALL in the download from github.
  
When setting up your HTPC / MythTV system, its best to set the following
+
== Post-install tasks  ==
 +
After installing the software there are a number of steps that must be taken before you have a working environment. If you installed from a pre-built package these would be done automatically.
  
'''For Ubuntu'''
+
=== Creating the mythtv user ===
Volume: the volume control is on the top panel by default. Set this to max.  
+
MythTV backend needs to run as its own user. This should be a system account. Create a user as follows:
Power Management: System->Preferences->Power Management - "Put display to sleep when inactive for" move the slider to the far right (never)
+
<pre>sudo useradd --system mythtv</pre>
Screensaver: System->Preferences->Screensaver - uncheck "Activate screensaver when computer is idle"
+
Users might want to add ''--groups cdrom,audio,video'' to the above.
System Bell: System->Preferences->Sound - in the "System Beep" tab, uncheck "Enable system beep" and check "Visual System Beep".  
 
  
 +
=== MythTV Database Setup ===
 +
Run these commands from the command line. The mysql command will prompt for your root database password, which you would have supplied during mysql installation. The mysql daemon must be running.
 +
<pre>mysql -u root -p
 +
create database mythconverg;
 +
create user 'mythtv'@'%' identified by 'mythtv';
 +
create user 'mythtv'@'localhost' identified by 'mythtv';
 +
set password for 'mythtv'@'%' = password('mythtv');
 +
set password for 'mythtv'@'localhost' = password('mythtv');
 +
connect mythconverg;
 +
grant all privileges on *.* to 'mythtv'@'%' with grant option;
 +
grant all privileges on *.* to 'mythtv'@'localhost' with grant option;
 +
flush privileges;
 +
exit;</pre>
 +
Run the following command [[MySQL_Time_Zone_Tables|to set up time zone tables]]:
 +
<pre>mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql</pre>
 +
Ignore warnings like "Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.".
  
 +
Run mythbackend. This will automatically create your database or upgrade your previous mythconverg database schema to the latest version:
 +
<pre>mythbackend</pre>
 +
mythbackend will start up and create the database tables, after which it will shut down. Further attempts to start it will result in a message as follows:
 +
<pre>
 +
E  Scheduler: No capture cards are defined in the database.
 +
Perhaps you should re-read the installation instructions?
 +
</pre>
 +
If there are problems with the database, see the article [[Database Setup]].
  
 +
Before you can get the backend to start up and stay running, you have to configure at least one capture card correctly, plus one video source and connect these with an input. See [[Configuring_MythTV]]. Note that if you had installed the Ubuntu pre-built package there would not be this restriction, the backend can run without any configuration being done.
  
 +
=== Backend Startup ===
 +
For MythTV to be able to schedule and make recordings, the backend must be running at the time of the scheduled recordings. Normally this means running the backend at all times while the server is running. It should be set up to be automatically started when the server starts. This is handled automatically for you in the pre-built packages, but if you are building it yourself you have to set up some mechanism. Possible ways of doing it are ''[[Systemd_mythbackend_Configuration|systemd]]'', ''[[Upstart_mythbackend_Configuration|Upstart]]'', ''init script'', ''/etc/rc.local''. Ubuntu packages run it from Upstart (but is likely to switch to systemd in 16.04), which has the ability to restart the process if it fails.
  
==Setup MythTV backend preferences and tune TV cards==
+
The simplest way will be by editing the rc.local. Use ''gksudo gedit'' to edit rc.local and add the following line:
 +
<pre>/usr/local/bin/mythbackend -d --logpath /tmp/ --user mythtv</pre>
 +
This is a very basic and simplistic approach, but will work. For a reliable system you need to use something more advanced like Upstart. If you install from the Ubuntu or MythBuntu package the Upstart setup is done for you. Also you should create a directory other than /tmp/ for your logs. ''/var/log/mythtv'' is the popular location. Note that whatever directory you create for logs must be writeable by the mythtv user as well as frontend users. The frontend user if your normal Linux login, which you will use for viewing MythTV.
  
Open a Terminal Window and type
+
You can get a list of options available with mythbackend by running ''mythbackend --help''.
  
> mythtv-setup
+
If the backend starts up before you have added any capture cards it will immediately shut down again. Proceed to [[Configuring MythTV]] and complete the configuration up to the point of setting up a capture card, a video source and an input connection, before trying to start it again.
  
You will now see the GUI for MythTV to setup the backend server and in particular the channel tuning for our broadcast streams. You will need to set up:
+
==Next Steps==
 +
At this point you need to perform the configuration steps. See the table of contents and proceed to [[Configuring_MythTV]] and then [[Configuring_Frontend]]. Until you have done that you will not be able to do anything useful with MythTV.
  
#General &mdash; General Backend settings, most user can use the defaults
+
[[Category:Distribution_Specific_Install_Guides]]
#Capture Cards &mdash; you will configure your capture cards/devices here
 
#Video Sources &mdash; create guide data.
 
#Input connections &mdash; connect the Capture Card name to the Video Source
 
#Channel Editor &mdash; scan for your channels here
 
#Storage Groups &mdash; Configure which folders your recordings will be saved.
 
 
 
On entering each screen, the cursor is positioned at the bottom right on the "Next" button.  The cursor may not be visible.  Use the up, down, left, and right cursor keys to make selections.  Fields marked with up and down arrows can be modified by pressing the PageUp and PageDown keys or the left and right cursor keys; in some cases, the action is different.  For example, when setting times, cursor left and cursor right change the time by minutes, while Page Up and Page Down change by half hours.  Some fields, notably text fields, accept direct keyboard input.  For many fields, context-sensitive help appears in the bottom part of the screen when you position on the field.
 
 
 
===Multiple tuner cards===
 
 
 
If you have more than one TV card, you only need to do the channel scan on one of the cards. All cards of the same type should point to the same video source. For example let's say you have two cards both for Freeview (UK Network). Create a Video Source called FreeviewUK, now connect both cards to this Video source.
 
 
 
[DVB1] DVB card 1->FreeviewUK
 
 
 
[DVB0] DVB card 2->FreeviewUK
 
  
http://acaciaclose.co.uk/mediac/400_0/media/mythtune.jpg
+
[[Category:Software Installation|1800]]
 
 
When you scan for your channels make sure that you put in a frequency that corresponds to the transmitter that you will be receiving from, for instance Crystal Palace. You can find out the frequency on the web for your country and region.
 
 
 
Older TV cards may need all of the parameters from the transmitters tab to be entered, and not just left as "auto". The next version of MythTV (0.19) should have a "blind" scan, and it should just find the channels for you.
 
 
 
Alternatively users in the USA using Schedules Direct can fetch there lineups form Schedules Direct in Input Connections to automatically configure channel lineups.
 
 
 
 
 
=More info=
 
 
 
[1] See [[Ubuntu Installation Guides]] for installing on other Ubuntu versions.
 
 
 
 
 
 
 
 
 
=Previous information to integrated in the text above=
 
 
 
==The setup==
 
 
 
There are four key parts to MythTV, and setup roughly in this order:
 
#Start system services that MythTV needs
 
#Initialize the system database, mythconverg
 
#Setup system preferences and tune your TV card using mythtv-setup
 
#Start main MythTV server, mythtvbackend
 
#Start MythTV, mythfrontend
 
 
 
'''Create a user called mythtv and do all of the following steps as this user'''
 
 
 
Its a good idea to run these from a terminal window to start with, so we can see that everything is as it should be. Once all has been set up and complete, then we can run mysql/mythbackend/frontend as background server processes.
 
 
 
==Start system services==
 
 
 
We need to have both "mysql" and "mythbackend" running on startup
 
 
 
[[Image:Geeko_head48.png|25px]] openSUSE
 
 
 
Start YaST -> System ->System Services ( RunLevel)
 
 
 
Select mysql      click "enable"  Click OK after popup dialog
 
 
 
Select ntp          click  "enable"  Click OK after popup dialog
 
 
 
Notice there is a mythbackend option, would suggest that you do not enable "mythbackend" just yet, until you have tried running in a terminal window as below. If all steps below work then enable this to run.
 
 
 
==Setup mysql database mythconverg==
 
 
 
Set the root password for the mysql database. (replace mysqlpassword with your own)
 
 
 
Open a Terminal window
 
 
 
> mysqladmin -u root password  mysqlpassword
 
 
 
Setup the initial database.
 
Note - the mc.sql file should have been installed along with the mythtv documentation onto your system.  The default location for this file is shown below, however it may have been relocated elsewhere according to your distribution's documentation rules, so you may have to use a search (find, locate, etc) tool to reveal its whereabouts.
 
Suse 11.0 -- mc.sql is at "/usr/share/doc/packages/mythtv-doc/database/mc.sql"
 
(The following command will prompt for password)
 
 
 
> mysql -u root -p  < /usr/share/mythtv/database/mc.sql
 
 
 
'''How to Reset the Root Password (Slackware):'''
 
 
 
Login as a root
 
 
 
> su -
 
 
 
Stop the database
 
 
 
> /etc/rc.d/rc.mysqld stop
 
 
 
Set the initial file for a new root database password
 
 
 
> echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');" > /var/lib/mysql/mysql-init
 
 
 
Change the user and group ownership
 
 
 
> chown mysql.mysql /var/lib/mysql/mysql-init
 
 
 
Start a database manually
 
 
 
> /usr/bin/mysqld_safe --init-file=/var/lib/mysql/mysql-init &
 
 
 
Login to the database as a root with a new password
 
 
 
> mysql -u root -p new_password
 
 
 
[http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html How to Reset the Root Password]
 
 
 
[[Category:HOWTO]]
 
[[Category:Distribution_Specific_Install_Guides]]
 
[[Category:Ubuntu]]
 

Revision as of 15:51, 30 April 2016

Software-update-available.png This page is up-to-date as of MythTV version 0.28, the current release is 34.0

Introduction

For most people, it will be far easier to install a pre-built package for MythTV rather than building from source. Reasons for building from source include:

  • There is no pre-built package for your Linux distribution.
  • The pre-built package for your distribution is out of date.
  • You want to run a pre-release version of the software.
  • Users choose to test/write patches.

If you have already installed a pre-built package and you have a need to try out a source code change, it would be preferable to use your distribution's build process to build a version that is compatible with the already installed version. There are differences in the placement of files between the downloaded packages and the code you build yourself.

This guide shows how to build from source code downloaded from github.

Raspberry Pi

Starting from version 0.28 It is possible to build and run MythTV frontend on a Raspberry Pi 2 or Raspberry Pi 3. Since the Raspberry Pi has limited resources there are some steps you can take to ensure a successful build.

Setting up a Raspberry Pi for building MythTV
MythTV can be built on any linux variant that runs on Raspberry Pi. That includes Raspbian, Ubuntu Mate, Arch Linux. Before attempting to build you should take these steps.


Install the operating system on an external USB hard drive.

Use a hard drive that has its own power supply. If you have an old hard drive around that you no longer use you can buy a USB enclosure for it. You need a hard drive of 50 GB or more.

These steps can be done on the Raspberry Pi itself but are easier if done from an desktop computer running Linux.

  • Install your Raspberry Pi operating system on an SD card as normal. If you are going to use the Raspberry Pi to prepare the hard drive you will need to prepare a second SD card. Make sure your SD cards boot correctly into the operating system.
  • Partition your hard drive. Create an ext4 partition of at least 50 GB for your operating system. I recommend using gparted. Format it as ext4 (gparted can do that for you).
  • Copy your SD card contents to the new hard drive partition. If you are using the raspberry pi to do this do not copy the SD card from which you are booted. You will need an SD card reader plugged into a USB port to read the SD card that you are copying from. Use lsblk to determine the device names. If you are running a Graphical environment it may automatically mount the devices. Otherwise mount them in an appropriate place. On the SD card you are copying from use the second partition (e.g. /dev/sda2).
sudo cp -av /source/directory/* /dest/directory/
  • Edit the /boot/cmdline.txt file on the SD card you are copying from. Change the parameter root=/dev/mmcblk0p2 to root=/dev/sda1. If you are not using the first partition on the hard drive change sda1 to the correct partition.
  • Edit the /etc/fstab file on the hard drive. Find the line for the root mount. Change the device name at the beginning of the line from /dev/mmcblk0p2 to /dev/sda1, or the correct hard drive partition.
  • Shut down your raspberry pi, insert the SD card you were copying from, and plug in the external hard drive. Make sure you do not have another drive or USB Card reader plugged in. The raspberry pi will now boot with the hard drive as root partition.


Increase swap space

On your hard drive based system, run the following commands.

sudo apt-get install dphys-swapfile
sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall

edit the file /etc/dphys-swapfile and set CONF_SWAPSIZE=2048

sudo dphys-swapfile setup
sudo dphys-swapfile swapon

This should give you 2GB swap space. To check it run top. You should see KiB Swap: 2097148 total,.


Reduce GPU memory

Edit /boot/config.txt and set to following

gpu_mem=128

In my experience this is sufficient for the video that is supported by MythTV. If not you can increase it when you are no doing builds.


Setup ccache

After installing the prerequisites make sure there is enough ccache as follows

ccache -M 5G -F 0

With all of these steps in place, the first build of MythTV will take around 2 hours on a Raspberry Pi 2. Subsequent builds can take as little as 2 minutes. With ccache, even a full rebuild can complete in 10 minutes, because it caches the compiler results and if the source does not change it re-uses them.

Dependencies

One of the most difficult parts of building the code is getting the correct dependencies installed first. The syntax for installing these will vary from one distribution to another, and package names may also vary between distributions.

Installing Build Dependencies with Ansible

Mythtv now has Ansible playbooks to set up build dependencies. These support many Linux variants and will easily install your build dependencies. Follow the following steps to install build dependencies.

  • Install git using your distribution package system.
  • Follow steps described at https://github.com/MythTV/ansible. For MythTV version 0.28 onwards, use the option "For a normal development system running Qt5". For earlier versions use "For a normal development system running Qt4". All of the commands listed on that page must be run as root or with sudo. Note that 0.27 can run with either QT4 or QT5, and the choice will depend on what is available with your release of Linux.

Installing Build Dependencies without Ansible

It is recommended to use Ansible, because that will be kept up to date. Alternatively, to install the dependencies manually, follow these instructions.

Build Dependencies for version 0.27
All Environments build-essential ccache yasm libqt4-dev libqtwebkit-dev libqt4-opengl-dev po-debconf texi2html linux-kernel-headers libdvdnav-dev libfreetype6-dev libavc1394-dev libiec61883-dev liblircclient-dev libxinerama-dev libxxf86vm-dev libxvmc-dev libxext-dev libimlib2-dev libasound2-dev libmp3lame-dev libvorbis-dev libdts-dev lsb-release libpulse-dev libxrandr-dev libfftw3-dev libva-dev libvdpau-dev libudev-dev libclass-dbi-perl libnet-upnp-perl libio-socket-inet6-perl libdbd-mysql-perl libjson-perl libwww-perl python-oauth python-lxml python-mysqldb python-pycurl python-urlgrabber libgl1-mesa-dev libdvdread-dev fftw-dev libvorbis-dev libflac-dev libmad0-dev libcdaudio-dev libcdio-dev libcdparanoia-dev libsdl1.2-dev libfaad-dev libexif-dev libtiff5-dev libxv-dev libtag1-dev libvisual-0.4-dev libmysqlclient-dev libdate-manip-perl libxml-simple-perl libimage-size-perl libdatetime-format-iso8601-perl libsoap-lite-perl libx264-dev libvpx-dev libavahi-compat-libdnssd-dev libssl-dev libcdio-cdda-dev libcdio-paranoia-dev libxml2-dev libass-dev libcec-dev uuid-dev libxml-xpath-perl libtool-bin
i386/amd64 Add this: libcrystalhd-dev
debian-wheezy

ubuntu-precise

replace libtiff5-dev with libtiff4-dev (avoids conflict in libimlib2-dev).
Notes

If you are building a Debian or Ubuntu package using dpkg-buildpackage you will need these additional packages: debhelper quilt dh-python dh-systemd

On debian-wheezy and ubuntu-precise replace dh-python with python-central (avoids backports).

Build Dependencies for version 0.28
All Environments build-essential ccache yasm help2man qtdeclarative5-dev libqt5webkit5-dev libqt5opengl5-dev qtscript5-dev qt5-qmake po-debconf linux-kernel-headers libdvdnav-dev libfreetype6-dev libavc1394-dev libiec61883-dev liblircclient-dev libxinerama-dev libxxf86vm-dev libxvmc-dev libxext-dev libimlib2-dev libasound2-dev libmp3lame-dev libvorbis-dev libdts-dev lsb-release libpulse-dev libxrandr-dev libfftw3-dev libva-dev libvdpau-dev libudev-dev libclass-dbi-perl libnet-upnp-perl libio-socket-inet6-perl libdbd-mysql-perl libjson-perl libwww-perl python python-oauth python-lxml python-mysqldb python-pycurl python-urlgrabber libgl1-mesa-dev libdvdread-dev fftw-dev libvorbis-dev libflac-dev libmad0-dev libcdaudio-dev libcdio-dev libcdparanoia-dev libsdl1.2-dev libfaad-dev libexif-dev libtiff5-dev libxv-dev libtag1-dev libvisual-0.4-dev libmysqlclient-dev libdate-manip-perl libxml-simple-perl libimage-size-perl libdatetime-format-iso8601-perl libsoap-lite-perl libx264-dev libvpx-dev libavahi-compat-libdnssd-dev libssl-dev libcdio-cdda-dev libcdio-paranoia-dev libxml2-dev libass-dev libcec-dev libexiv2-dev uuid-dev libxml-xpath-perl git hello libtool-bin
i386/amd64 Add this: libcrystalhd-dev
debian-wheezy replace libtiff5-dev with libtiff4-dev (avoids conflict in libimlib2-dev).

wheezy will require wheezy-backports repository to then automatically pull in qt5

raspberry pi Add this: libraspberrypi-dev
Notes If you are building a Debian or Ubuntu package using dpkg-buildpackage you will need these additional packages:

debhelper quilt dh-python

On debian-wheezy replace dh-python with python-central (avoids backports).

Run Time Dependencies

If you are installing on a different computer from where you built, you will need the run time dependencies. You do not need the full list of build dependencies. Here is a list of runtime dependencies.

Run Time Dependencies for version 0.27
mysql-server ntp libicu48 libqt4-sql-mysql
Run Time Dependencies for version 0.28
mysql-server-5.6 ntp libicu55 libqt5sql5-mysql mysql-client-5.6
Run Time Dependencies for MythWeb
All Environments apache2 php5 php5-mysql libhttp-date-perl
Ubuntu Xenial or where php5 is not available apache2 php7 php7-mysql libhttp-date-perl

The package mysql-server only needs to be installed on one backend, normally the master backend, or it can be installed on a separate database server, although this would be unusual.

On systems that do not have mysql-server (e.g. remote frontends, slave backends), you need to install mysql-client instead.

Install the build dependencies on your build machine. Install the Run Time dependencies on your MythTV machine (which may be the same as the build machine). If you plan to use MythWeb, install those dependencies on your master backend system.

Distribution Install Command Additional packages
Ubuntu, Debian, MythBuntu, other Debian based distributions. sudo apt-get install Dependency List
build-essential

Depending on your distribution, run the install command with the list of packages.

Getting and compiling the source code

Step Command to run
create a directory cd
mkdir ~/build
clone cd ~/build
git clone https://github.com/MythTV/mythtv.git mythtv
cd mythtv
Check versions available git branch -a
Choose your version. The current stable released version is 33-fixes. We recommend to use that version. git checkout fixes/0.28
If you have previously done a build in this directory, run this if you need a complete rebuild git clean -xfd

In general, you should probably choose the stable version. If you don't mind if your MythTV system is non-functional or has serious bugs that may prevent proper operation/result in lost recordings or inability to play back recordings, you may try using the unstable, development code. If using unstable, development code, you should follow the mythtv-commits and mythtv-dev mailing lists.

Build and Install MythTV

In the ~/build/mythtv/mythtv directory, run the ./configure script. You can see available options by using the --help parameter with configure:

./configure --help

By default the build will install mythtv in a directory structure under /usr/local/. Executables will be in /usr/local/bin. You can modify this behavior with the --prefix= parameter. The default prefix is /usr/local.

Normally you will not need to supply any options to configure, although 0.27 users should add --disable-mythlogserver (mythlogserver). Run it as follows:

Distribution Command to run
Raspbian,
Ubuntu MATE for Raspberry Pi
Note: Raspberry pi is only supported with version 0.28 or later

export CFLAGS="-I/opt/vc/include -I/opt/vc/include/IL -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
export CXXFLAGS="-I/opt/vc/include -I/opt/vc/include/IL -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
export LDFLAGS="-L/opt/vc/lib"
./configure --compile-type=release --disable-mythlogserver --disable-crystalhd --enable-lirc --enable-audio-alsa --enable-audio-oss --enable-dvb --enable-ivtv --enable-firewire --enable-joystick-menu --with-bindings=perl --enable-ffmpeg-pthreads --enable-pic --perl-config-opts="INSTALLDIRS=vendor" --enable-libvpx --enable-sdl --enable-libmp3lame --enable-libx264 --disable-vdpau --disable-opengl-video --disable-opengl --disable-vaapi

Others ./configure --compile-type=release

If you want to build with debugging info, use --compile-type=profile. There are problems with using debug as the compile type.

The configure step may identify dependencies that are missing. If so you will need to find them and install them before continuing. Please let us know via an update to this page or make a comment in th discussion page.

If the configure was successful, run the build as follows

make -j 5

The -j option is optional but can speed up the make by running multiple processes at the same time. Set the number to 1 higher than the number of cores in your system.
The build may identify missing dependencies. Install them and notify us via a comment in the discussion.
When the build is successful, install this way

sudo make install

This will install both backend and frontend software. Install this on all machines, backend or frontend. You will only start the backend on the backend machines. On frontend machines the backend software will exist but will not be used.

Build and Install Plugins

Building and installing the plugins is optional. I recommend that new users skip this step. Plugins are not needed for any of the main functionality of MythTV, including watching Videos and watching DVDs. Plugins are for Music, Weather, YouTube, Games, etc.

Plugins are only used on the frontend, so if you have a separate backend you need not install them on the backend.

The plugins build requires that you have first completed a build of mythtv and installed it. It makes use of some of the items set up in the mythtv configure step, and some of the items installed in the install step, so if you have cleaned your mythtv build, the plugins build will not work.

In the ~/build/mythtv/mythplugins directory, run the same commands as above for building and installing MythTV. If you only want to build certain plugins, you can disable the others in the ./configure command (check the --help for the syntax for that).

./configure
make -j 5
sudo make install

Shared-Library requirements for MythTV

The runtime manager for shared libraries, /lib/ld.so, gets information about the locations and contents of shared libraries from /etc/ld.so.cache, a file created by ldconfig from information in /etc/ld.so.conf. Because MythTV installs shared libraries in /usr/local/lib, that directory needs to be added to the list of directories for ld.so to search when doing runtime linking of programs, if it is not already there. You do this, as root, by editing /etc/ld.so.conf, then running ldconfig. There are many ways to do this; to determine the way that your distribution is configured, type:

cat /etc/ld.so.conf
cat /etc/ld.so.conf.d/*

Check if /usr/local/lib is included in the list displayed. If so then no action is needed.

If /usr/local/lib is not already included, then create as root a file under /etc/ld.so.conf.d that contains a line containing

/usr/local/lib

Make sure that /etc/ld.so.conf contains a line as follows

include /etc/ld.so.conf.d/*.conf

To ensure the cache has been updated, run this command:

sudo /sbin/ldconfig

Test Setup

Instead of setting up the shared library cache as described above, if you have customized the location of the libraries using for example ./configure --prefix=/home/peter/work/mythtv, you can install and run the backend and frontend in your home directory by setting the path of the lib files as follows:

export LD_LIBRARY_PATH=/home/peter/work/mythtv/lib
export PATH="$PATH:/home/peter/work/mythtv/bin"

Install MythWeb

If you plan to run MythWeb, install it on your master backend server. Install the dependencies, listed above. Check out Mythweb from git:

Step Command to run
clone cd ~/build
git clone https://github.com/MythTV/mythweb.git mythweb
cd mythweb
Check versions available git branch -a
Choose your version. The current stable released version is 33-fixes. We recommend to use that version. git checkout fixes/0.xx

Set up the web application as follows:

cd ~/build/mythweb/
sudo cp -r ~/build/mythweb /usr/local/share/mythtv/mythweb
sudo ln -s /usr/local/share/mythtv/mythweb/ /var/www/html/
sudo cp -v /usr/local/share/mythtv/mythweb/mythweb.conf.apache /etc/apache2/sites-available/mythweb.conf

Edit file /etc/apache2/sites-available/mythweb.conf using gedit or vi, for example:

sudo vi /etc/apache2/sites-available/mythweb.conf

Change the lines containing <Directory "/var/www/html/data"> and <Directory "/var/www/html" > so that they read <Directory "/var/www/html/mythweb/data"> and <Directory "/var/www/html/mythweb" >, i.e. add the mythweb subdirectory.

sudo a2enmod rewrite
sudo a2ensite mythweb.conf
sudo chown -R www-data:www-data /usr/local/share/mythtv/mythweb/data/
sudo chmod -R g+w /usr/local/share/mythtv/mythweb/data/

Restart your apache server as follows to get the changes applied:

sudo /etc/init.d/apache2 restart

the database and backend must be running for MythWeb to work. At this point you have not yet set up the database or the backend so you cannot try MythWeb. Once those things have been set up and are running, test MythWeb by navigating to http://servername/mythweb where servername is your master backend server on which mythweb is running. If running from a different system you may have to add servername plus its ip address to your /etc/hosts file.

For more advanced and detailed instructions on MythWeb see the file mythweb/INSTALL in the download from github.

Post-install tasks

After installing the software there are a number of steps that must be taken before you have a working environment. If you installed from a pre-built package these would be done automatically.

Creating the mythtv user

MythTV backend needs to run as its own user. This should be a system account. Create a user as follows:

sudo useradd --system mythtv

Users might want to add --groups cdrom,audio,video to the above.

MythTV Database Setup

Run these commands from the command line. The mysql command will prompt for your root database password, which you would have supplied during mysql installation. The mysql daemon must be running.

mysql -u root -p
create database mythconverg;
create user 'mythtv'@'%' identified by 'mythtv';
create user 'mythtv'@'localhost' identified by 'mythtv';
set password for 'mythtv'@'%' = password('mythtv');
set password for 'mythtv'@'localhost' = password('mythtv');
connect mythconverg;
grant all privileges on *.* to 'mythtv'@'%' with grant option;
grant all privileges on *.* to 'mythtv'@'localhost' with grant option;
flush privileges;
exit;

Run the following command to set up time zone tables:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

Ignore warnings like "Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.".

Run mythbackend. This will automatically create your database or upgrade your previous mythconverg database schema to the latest version:

mythbackend

mythbackend will start up and create the database tables, after which it will shut down. Further attempts to start it will result in a message as follows:

 E  Scheduler: No capture cards are defined in the database.
 Perhaps you should re-read the installation instructions?

If there are problems with the database, see the article Database Setup.

Before you can get the backend to start up and stay running, you have to configure at least one capture card correctly, plus one video source and connect these with an input. See Configuring_MythTV. Note that if you had installed the Ubuntu pre-built package there would not be this restriction, the backend can run without any configuration being done.

Backend Startup

For MythTV to be able to schedule and make recordings, the backend must be running at the time of the scheduled recordings. Normally this means running the backend at all times while the server is running. It should be set up to be automatically started when the server starts. This is handled automatically for you in the pre-built packages, but if you are building it yourself you have to set up some mechanism. Possible ways of doing it are systemd, Upstart, init script, /etc/rc.local. Ubuntu packages run it from Upstart (but is likely to switch to systemd in 16.04), which has the ability to restart the process if it fails.

The simplest way will be by editing the rc.local. Use gksudo gedit to edit rc.local and add the following line:

/usr/local/bin/mythbackend -d --logpath /tmp/ --user mythtv

This is a very basic and simplistic approach, but will work. For a reliable system you need to use something more advanced like Upstart. If you install from the Ubuntu or MythBuntu package the Upstart setup is done for you. Also you should create a directory other than /tmp/ for your logs. /var/log/mythtv is the popular location. Note that whatever directory you create for logs must be writeable by the mythtv user as well as frontend users. The frontend user if your normal Linux login, which you will use for viewing MythTV.

You can get a list of options available with mythbackend by running mythbackend --help.

If the backend starts up before you have added any capture cards it will immediately shut down again. Proceed to Configuring MythTV and complete the configuration up to the point of setting up a capture card, a video source and an input connection, before trying to start it again.

Next Steps

At this point you need to perform the configuration steps. See the table of contents and proceed to Configuring_MythTV and then Configuring_Frontend. Until you have done that you will not be able to do anything useful with MythTV.