Amarok/Development/Development HowTo: Difference between revisions

From KDE Community Wiki
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Development Environment ==
== Development Environment ==


Amarok 2.7 requires KDE 4.8.3, Taglib 1.7, [http://amarok.kde.org/wiki/Development/MySQL_Embedded mysqld] and the development headers thereof. Make sure you have [http://amarok.kde.org/wiki/Development/Nepomuk strigi]'s streamanalyzers installed (libstreamanalyzer-dev and libstrigiqtdbusclient-dev on ubuntu). Optional packages include the latest version (1.0.0) of [http://libmtp.sourceforge.net/ libmtp]. Look [http://www.kde.org/download/distributions.php here] for help with various distributions. Currently Amarok 2 depends on embedded MySQL. Embedded MySQL is only supported in the 5.1 series. See this [http://mail.kde.org/pipermail/amarok/2008-September/006779.html thread] on the mailing list for help.
See the [https://invent.kde.org/multimedia/amarok/-/blob/master/README README] for a complete list of dependencies.


See the [http://projects.kde.org/projects/amarok/repository/revisions/master/entry/README README] for a complete list of dependencies.
More: [https://community.kde.org/Amarok/Development/Git Amarok Git Tutorial]
 
More: [http://techbase.kde.org/Getting_Started/Sources/Amarok_Git_Tutorial Getting Started/Sources/Amarok Git Tutorial]


== Building Amarok ==
== Building Amarok ==
Line 13: Line 11:
Installing Amarok locally will put it in your $HOME folder, making everything much easier to maintain. [http://blogs.fsfe.org/myriam/2009/09/compiling-amarok-from-git-locally-full-summary/ Source] Please refer to the source if something doesn't work as it should despite you having followed each step. Also be aware that sometimes upstream changes can cause problems, but we try our best to keep this page updated. In case of problems you can also ask in #amarok on irc.freenode.net. Please be patient and don't leave after a few minutes, we are often busy with real life :)
Installing Amarok locally will put it in your $HOME folder, making everything much easier to maintain. [http://blogs.fsfe.org/myriam/2009/09/compiling-amarok-from-git-locally-full-summary/ Source] Please refer to the source if something doesn't work as it should despite you having followed each step. Also be aware that sometimes upstream changes can cause problems, but we try our best to keep this page updated. In case of problems you can also ask in #amarok on irc.freenode.net. Please be patient and don't leave after a few minutes, we are often busy with real life :)


==== Install git, the compiler and KDE 4 development packages ====
==== Install git, the compiler and KDE 5 development packages ====


In Kubuntu, Debian, and all their derivatives:
In Kubuntu, Debian, and all their derivatives:
Line 96: Line 94:
* libwrap0-dev, needed as a dependency for MySQL. For OpenSuSE users, the package to install is tcpd-devel
* libwrap0-dev, needed as a dependency for MySQL. For OpenSuSE users, the package to install is tcpd-devel
   
   
===== Changes in MySQL for Kubuntu Oeniric and Debian Sid =====
Mysqlclient was moved in these distros with the arrival of mysql 5.5, so mysql_config no longer reports mysql_pic. To correct this you need to patch a few files. Find below the patch by Jonathan Riddell:
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4241e69..41b3412 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -957,7 +957,7 @@ if(KDE4_BUILD_TESTS)
  endif()
 
  if( NOT BUILD_MYSQLE_COLLECTION )
-    target_link_libraries(amaroklib ${MYSQL_LIBRARIES} ${ZLIB_LIBRARIES})
+    target_link_libraries(amaroklib ${MYSQL_LIBRARIES} -L/usr/lib/mysql ${ZLIB_LIBRARIES})
  endif( NOT BUILD_MYSQLE_COLLECTION )
 
  if(WIN32)
diff --git a/src/core-impl/collections/db/sql/mysqlecollection/CMakeLists.txt b/src/core-impl/collections/db/sql/mysqlecollection/CMakeLists.txt
index 7218d54..07c5b6e 100644
--- a/src/core-impl/collections/db/sql/mysqlecollection/CMakeLists.txt
+++ b/src/core-impl/collections/db/sql/mysqlecollection/CMakeLists.txt
@@ -36,6 +36,7 @@ target_link_libraries(amarok_collection-mysqlecollection
      ${QT_QTCORE_LIBRARY}
      ${QT_QTGUI_LIBRARY}
      ${MYSQL_EMBEDDED_LIBRARIES}
+    -L/usr/lib/mysql
      ${CMAKE_DL_LIBS}
      ${ZLIB_LIBRARIES}
  )
diff --git a/src/core-impl/collections/db/sql/mysqlservercollection/CMakeLists.txt b/src/core-impl/collections/db/sql/mysqlservercollection/CMakeLists.txt
index 3312e14..72196ae 100644
--- a/src/core-impl/collections/db/sql/mysqlservercollection/CMakeLists.txt
+++ b/src/core-impl/collections/db/sql/mysqlservercollection/CMakeLists.txt
@@ -36,6 +36,7 @@ target_link_libraries(amarok_collection-mysqlservercollection
      ${QT_QTCORE_LIBRARY}
      ${QT_QTGUI_LIBRARY}
      ${MYSQL_LIBRARIES}
+    -L/usr/lib/mysql
      ${CMAKE_DL_LIBS}
      ${ZLIB_LIBRARIES}
  )
To apply this patch, save the patch to kubuntu_mysqld-pic.diff, go to the amarok/ folder of your git checkout and type
patch -p1 < kubuntu_mysqld-pic.diff
==== Create folders ====
==== Create folders ====


Line 149: Line 101:
==== Checking out and Building ====
==== Checking out and Building ====


Now you need a source checkout from git.kde.org. In the folder ~/kde/src/, type the following command:
Now you need a source checkout from invent.kde.org. In the folder ~/kde/src/, type the following command:


  git clone git://anongit.kde.org/amarok.git
  git clone https://invent.kde.org/multimedia/amarok.git


this will drag approx. 55-60Mb of data, depending on the moment you actually make this checkout.
this will drag approx. 55-60Mb of data, depending on the moment you actually make this checkout.
Line 165: Line 117:
  cmake -DCMAKE_INSTALL_PREFIX=$HOME/kde -DCMAKE_BUILD_TYPE=debugfull -DWITH_MP4=ON -DWITH_ASF=ON $HOME/kde/src/amarok
  cmake -DCMAKE_INSTALL_PREFIX=$HOME/kde -DCMAKE_BUILD_TYPE=debugfull -DWITH_MP4=ON -DWITH_ASF=ON $HOME/kde/src/amarok


NOTE: if you previously used the ''git'' URL rather than ''anongit'', run this command:
git remote set-url origin git://anongit.kde.org/amarok
This will reset your git config file.
==== Updating KDE Config ====
kbuildsycoca4 --noincremental


Note: this might not be necessary for most of the cases
Now you are ready to run Amarok 2 by typing “amarok” in the shell. We strongly recommend you run amarok with the -d and --nofork option, so you will have debugging enabled and can get a valid backtrace if Amarok crashes.
 
Now you are ready to run Amarok 2.x by typing “amarok” in the shell. We strongly recommend you run amarok with the -d and –nofork option, so you will have debugging enabled and can get a valid backtrace if Amarok crashes.


==== Updating your Amarok build ====
==== Updating your Amarok build ====
Line 188: Line 129:
This will update your local git branch.  
This will update your local git branch.  


NOTE: if you previously used the ''git'' URL rather than ''anongit'', run this command:
git remote set-url origin git://anongit.kde.org/amarok
This will reset your git config file.


If you have done modifications to your local branch you would like to keep, make sure you update with the --rebase option. See also the git tutorial for KDE in section 10.
If you have done modifications to your local branch you would like to keep, make sure you update with the --rebase option. See also the git tutorial for KDE in section 10.
Line 210: Line 145:
Note: To be notified about major changes you definitely should subscribe to our mailing list [email protected] at https://mail.kde.org/mailman/listinfo/amarok-devel.  
Note: To be notified about major changes you definitely should subscribe to our mailing list [email protected] at https://mail.kde.org/mailman/listinfo/amarok-devel.  


Of course you will also find help in our #amarok channel on irc.freenode.net, but reading the mailing list is mandatory and spares us a lot of time.
Of course you will also find help in our #amarok channel on irc.libera.chat, but reading the mailing list is mandatory and spares us a lot of time.


Since you don’t want to repeat all this completely when you upgrade to a newer version of your preferred distribution, you should consider installing your /home directory on a separate partition from the start, it will spare you quite some time and hassle in the future.
Since you don’t want to repeat all this completely when you upgrade to a newer version of your preferred distribution, you should consider installing your /home directory on a separate partition from the start, it will spare you quite some time and hassle in the future.
Line 221: Line 156:
Amarok uses a unit test infrastructure that allows us to test the builds. If you consider contributing code to Amarok, you need to install Google Mock and you should build Amarok with the following cmake flag:
Amarok uses a unit test infrastructure that allows us to test the builds. If you consider contributing code to Amarok, you need to install Google Mock and you should build Amarok with the following cmake flag:


KDE4_BUILD_TESTS=ON
BUILD_TESTING=ON


For more information about the test infrastructure, read the Qtestlib Manual
For more information about the test infrastructure, read the Qtestlib Manual
Line 232: Line 167:
To build from source you need to install git on your computer, then download the sources with the following command:
To build from source you need to install git on your computer, then download the sources with the following command:


  git clone git://anongit.kde.org/amarok.git
  git clone https://invent.kde.org/multimedia/amarok.git


For updates you can then just use the command
For updates you can then just use the command
Line 243: Line 178:
  mkdir build
  mkdir build
  cd build
  cd build
  cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` -DCMAKE_BUILD_TYPE=debugfull -DKDE4_BUILD_TESTS=ON .. && make && make install
  cmake -DCMAKE_INSTALL_PREFIX=`kf5-config --prefix` -DCMAKE_BUILD_TYPE=debugfull -DBUILD_TESTING=ON .. && make && make install


Note that your cmake preferences are saved in CMakeCache.txt, so you don't have to have the -D options every time you run cmake.
Note that your cmake preferences are saved in CMakeCache.txt, so you don't have to have the -D options every time you run cmake.

Latest revision as of 12:27, 1 June 2024

Development Environment

See the README for a complete list of dependencies.

More: Amarok Git Tutorial

Building Amarok

Building Locally

Installing Amarok locally will put it in your $HOME folder, making everything much easier to maintain. Source Please refer to the source if something doesn't work as it should despite you having followed each step. Also be aware that sometimes upstream changes can cause problems, but we try our best to keep this page updated. In case of problems you can also ask in #amarok on irc.freenode.net. Please be patient and don't leave after a few minutes, we are often busy with real life :)

Install git, the compiler and KDE 5 development packages

In Kubuntu, Debian, and all their derivatives:

sudo apt-get install git-core build-essential kdesdk kdelibs5-dev libkonq5-dev kdebase-workspace-dev 

As well as a basic KDE installation, formerly provided by the now defunct kde-minimal metapackage:

* kdebase-runtime
* kdebase-workspace
* kdebase-apps
* plasma-desktop

I also highly recommend to install the oxygen-icon-theme and oxygen-icon-theme-complete, so you don’t have missing icons if you do not run KDE.

In Archlinux:

sudo pacman -Sy git base-devel kdelibs kdebase-runtime

In Gentoo:

sudo emerge -av dev-util/git kdelibs plasma-workspace

In OpenSuSE:

sudo zypper install git

In Fedora:

sudo yum install git kdelibs-devel

Install ccache to speed up compilation (optional, recommended)

ccache is a very nice tool that can speed up your compilation. It speeds up re-compilation of C/C++ code by caching previous compiles and detecting when the same compile is being done again. Install the package from your distribution (for those on Debian distros: sudo apt-get install ccache) and set the size of the cache to 2 GB with the command

ccache -M 2G

This will take 2Gb of space in your local directory, but the gain of time is really impressive. Enable the use of ccache by adding it to your local .bashrc, described below:

Using a text editor of your choice, open $HOME/.bashrc and append the following:

export PATH=$HOME/kde/bin:$PATH
export PATH=/usr/lib/ccache:$PATH
export LD_LIBRARY_PATH=$HOME/kde/lib:$LD_LIBRARY_PATH

Reload your edited .bashrc:

source $HOME/.bashrc

NOTE: if you are not using the bash shell, edit your proper shell config file (~/.zshrc or ~/.tcshrc or whatever it may be).

Make KDE aware of Amarok’s plugin location

mkdir ~/.kde/env  # okay if it exists
echo 'export KDEDIR=$HOME/kde' >> $HOME/.kde/env/myenv.sh
echo 'export KDEDIRS=$KDEDIR' >> $HOME/.kde/env/myenv.sh

Beware, some distributions call the above folder $HOME/.kde4/… (OpenSuSE in particular).

Make sure you have all the necessary dependencies

sudo apt-get build-dep amarok

For OpenSuSE users this would be

sudo zypper si -d amarok

For Fedora

yum-builddep amarok

The README file in the source is the reference for the dependency version, please refer to it in case of doubt.

Various dependencies that might cause compile errors and have to be installed

(these are rather specific to Kubuntu, might have other names in other distributions and/or are already installed)

  • libstrigiqtdbusclient-dev
  • libsearchclient-dev
  • libmysqlclient
  • libmysqlclient-dev
  • libmysqld-dev
  • libmysqld-pic
  • libwrap0-dev, needed as a dependency for MySQL. For OpenSuSE users, the package to install is tcpd-devel

Create folders

mkdir -p $HOME/kde/build/amarok
mkdir $HOME/kde/src

Checking out and Building

Now you need a source checkout from invent.kde.org. In the folder ~/kde/src/, type the following command:

git clone https://invent.kde.org/multimedia/amarok.git

this will drag approx. 55-60Mb of data, depending on the moment you actually make this checkout.

Everything is now ready to build:

cd $HOME/kde/build/amarok
cmake -DCMAKE_INSTALL_PREFIX=$HOME/kde -DCMAKE_BUILD_TYPE=debugfull $HOME/kde/src/amarok
make install

NOTE: if you want MP4 and ASF support you need to build with the following cmake line instead

cmake -DCMAKE_INSTALL_PREFIX=$HOME/kde -DCMAKE_BUILD_TYPE=debugfull -DWITH_MP4=ON -DWITH_ASF=ON $HOME/kde/src/amarok


Now you are ready to run Amarok 2 by typing “amarok” in the shell. We strongly recommend you run amarok with the -d and --nofork option, so you will have debugging enabled and can get a valid backtrace if Amarok crashes.

Updating your Amarok build

Since the development is quite fast with git, you should update your Amarok build regularly, and a daily checkout is not too much. This is made easy with the following command:

cd $HOME/kde/src/amarok
git pull

This will update your local git branch.


If you have done modifications to your local branch you would like to keep, make sure you update with the --rebase option. See also the git tutorial for KDE in section 10.

You can now simply build again with

cd $HOME/kde/build/amarok
make install

Since you have installed ccache, a full build will speed up over time. To have an idea about the build time, just type time make install when building. If you have several CPU cores, you can speed up even more with the -j[n] option, where [n] is the number of CPU cores +1. Of course, the more CPU you use for building, the less you will have available for other tasks

More information and useful links

Don’t forget: running a development version also means that it is not stable and can break anytime ! This is especially true after a feature freeze, when the developers merge their personal git branches to the master branch.

Note: To be notified about major changes you definitely should subscribe to our mailing list [email protected] at https://mail.kde.org/mailman/listinfo/amarok-devel.

Of course you will also find help in our #amarok channel on irc.libera.chat, but reading the mailing list is mandatory and spares us a lot of time.

Since you don’t want to repeat all this completely when you upgrade to a newer version of your preferred distribution, you should consider installing your /home directory on a separate partition from the start, it will spare you quite some time and hassle in the future.

Important information for code contributors

Amarok uses a unit test infrastructure that allows us to test the builds. If you consider contributing code to Amarok, you need to install Google Mock and you should build Amarok with the following cmake flag:

BUILD_TESTING=ON

For more information about the test infrastructure, read the Qtestlib Manual

Globally

A global install that puts Amarok in your main system directories which is fine unless something goes wrong and you want to get rid of it easily.


To build from source you need to install git on your computer, then download the sources with the following command:

git clone https://invent.kde.org/multimedia/amarok.git

For updates you can then just use the command

git pull --rebase

in the amarok source folder. Then follow the instructions below.

cd amarok
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=`kf5-config --prefix` -DCMAKE_BUILD_TYPE=debugfull -DBUILD_TESTING=ON .. && make && make install

Note that your cmake preferences are saved in CMakeCache.txt, so you don't have to have the -D options every time you run cmake.

ccmake .

will give you a nice ncurses interface