Development/Tutorials/Setting Up: Difference between revisions

From KDE TechBase
m (Mark for translation)
(Marked this version for translation)
Line 2: Line 2:


<translate>
<translate>
<!--T:1-->
Contrary to popular misconception, you don't have to install all of "KDE" (you can't download a community) or a monolithic kdelibs (no longer exists) just to develop KDE software. That's especially true if you just want to use just a few [[Frameworks|KDE Frameworks]] for your Qt project. You don't even need to compile anything at all! Except for your own project, of course. Granted, there are a few ways to go about using KDE libraries for your application so this page lists some of them, depending on your situation or need.
Contrary to popular misconception, you don't have to install all of "KDE" (you can't download a community) or a monolithic kdelibs (no longer exists) just to develop KDE software. That's especially true if you just want to use just a few [[Frameworks|KDE Frameworks]] for your Qt project. You don't even need to compile anything at all! Except for your own project, of course. Granted, there are a few ways to go about using KDE libraries for your application so this page lists some of them, depending on your situation or need.


= Installation =
= Installation = <!--T:2-->


== Prerequisites ==
== Prerequisites == <!--T:3-->


<!--T:4-->
This guide focuses mainly on setting up KDE Frameworks. Whether you build it from source or use your distro's packages, you will need a few other pieces to use them.
This guide focuses mainly on setting up KDE Frameworks. Whether you build it from source or use your distro's packages, you will need a few other pieces to use them.


<!--T:5-->
* Qt - as of 2019-06, the [[Community:Frameworks/Policies#Frameworks_Qt_requirements|required version]] is at least Qt 5.10
* Qt - as of 2019-06, the [[Community:Frameworks/Policies#Frameworks_Qt_requirements|required version]] is at least Qt 5.10


<!--T:6-->
* CMake - as of 2019, the required version is CMake 3.5
* CMake - as of 2019, the required version is CMake 3.5


<!--T:7-->
* Compiler - On Linux, GCC 4.8 and Clang 3.3 are required, enabling support for C++11 features
* Compiler - On Linux, GCC 4.8 and Clang 3.3 are required, enabling support for C++11 features


== Easy as pie: Package manager ==
== Easy as pie: Package manager == <!--T:8-->


<!--T:9-->
The easiest and safest way to use a KDE framework is to install it (or its development package) from your Linux distribution's package manager. Say you want to add some syntax highlighting to your Qt text editing widget. On KDE Neon or Kubuntu or Debian, this one line sets it all up:
The easiest and safest way to use a KDE framework is to install it (or its development package) from your Linux distribution's package manager. Say you want to add some syntax highlighting to your Qt text editing widget. On KDE Neon or Kubuntu or Debian, this one line sets it all up:
</translate>
</translate>
Line 26: Line 32:


<translate>
<translate>
<!--T:10-->
That's it! You can then proceed to [[#Using_KDE_Frameworks|actually using the framework]] in your app. Of course, this presumes that your distro has a more or less recent version of the framework in its repository or that you're fine with not using the latest. If not, proceed to Plan B.
That's it! You can then proceed to [[#Using_KDE_Frameworks|actually using the framework]] in your app. Of course, this presumes that your distro has a more or less recent version of the framework in its repository or that you're fine with not using the latest. If not, proceed to Plan B.


== Make it so! ==
== Make it so! == <!--T:11-->


<!--T:12-->
KDE Frameworks is released on a monthly basis to ensure that developers will always have access to bug fixes or new features as soon as possible. The Plasma workspaces and KDE applications have their own release schedules as well. Sometimes, however, distros don't always provide the latest version of KDE software that you might need. If that's the case, you might have to compile the framework from the source. Not to worry, it's not as daunting or complicated as in the past.
KDE Frameworks is released on a monthly basis to ensure that developers will always have access to bug fixes or new features as soon as possible. The Plasma workspaces and KDE applications have their own release schedules as well. Sometimes, however, distros don't always provide the latest version of KDE software that you might need. If that's the case, you might have to compile the framework from the source. Not to worry, it's not as daunting or complicated as in the past.


=== Step 1: Download the framework ===
=== Step 1: Download the framework === <!--T:13-->


<!--T:14-->
Download the latest version of the framework either [https://download.kde.org/stable/frameworks/ from tarballs] or [https://cgit.kde.org/kwidgetsaddons.git/ from Git]. Note that Git master will always have the latest version of the code and may not be stable, so be sure to checkout the stable tag for the release you need.
Download the latest version of the framework either [https://download.kde.org/stable/frameworks/ from tarballs] or [https://cgit.kde.org/kwidgetsaddons.git/ from Git]. Note that Git master will always have the latest version of the code and may not be stable, so be sure to checkout the stable tag for the release you need.
</translate>
</translate>
Line 42: Line 51:


<translate>
<translate>
=== Step 2: Build it! ===
=== Step 2: Build it! === <!--T:15-->


<!--T:16-->
Go into the directory of the downloaded/cloned framework and issue the following commands:
Go into the directory of the downloaded/cloned framework and issue the following commands:
</translate>
</translate>
Line 54: Line 64:


<translate>
<translate>
<!--T:17-->
Presuming you have the proper dependencies installed (you'll have to consult your distro's package manager), this should end in a successful build that's ready to install. Note that KDE software use an "out-of-source build" structure to make things cleaner and easier to clean up if needed.  
Presuming you have the proper dependencies installed (you'll have to consult your distro's package manager), this should end in a successful build that's ready to install. Note that KDE software use an "out-of-source build" structure to make things cleaner and easier to clean up if needed.  


=== Step 3: Install ===
=== Step 3: Install === <!--T:18-->


<!--T:19-->
This part is usually tricky. Normally, you'd issue the <code>make install</code> command at this point, which you can certainly do that if you already know the CMake trick. You can also use <code>sudo make install</code> but that would overwrite your system-installed version of the framework without prejudice. The safest way would be to install the framework [[Development/Tutorials/Using_Actions#Make.2C_Install_And_Run|somewhere in your home directory]], following the steps outlined in this tutorial. Do note you'll have to adjust some system environment variables so that your project will see the newly-installed framework.
This part is usually tricky. Normally, you'd issue the <code>make install</code> command at this point, which you can certainly do that if you already know the CMake trick. You can also use <code>sudo make install</code> but that would overwrite your system-installed version of the framework without prejudice. The safest way would be to install the framework [[Development/Tutorials/Using_Actions#Make.2C_Install_And_Run|somewhere in your home directory]], following the steps outlined in this tutorial. Do note you'll have to adjust some system environment variables so that your project will see the newly-installed framework.


== Use the source ==
== Use the source == <!--T:20-->


<!--T:21-->
KDE does have a tool that specializes in automating the above. It might be overkill for one-off use of frameworks but if you find yourself getting attached to more and more KDE Frameworks (which is definitely a good thing), you might want to give [[Community:Get_Involved/development#Set_up_kdesrc-build|the kdesrc_build tool]] a good try. It's especially useful for developers interested in leveling up to become KDE rockstars.
KDE does have a tool that specializes in automating the above. It might be overkill for one-off use of frameworks but if you find yourself getting attached to more and more KDE Frameworks (which is definitely a good thing), you might want to give [[Community:Get_Involved/development#Set_up_kdesrc-build|the kdesrc_build tool]] a good try. It's especially useful for developers interested in leveling up to become KDE rockstars.


= Using KDE Frameworks =
= Using KDE Frameworks = <!--T:22-->


<!--T:23-->
Made it this far? Congratulations! The brunt of the setup work is complete and you're ready to use that powerful new framework to boost your Qt application. If you're using QMake, all you need is to add a simple line to your project file:
Made it this far? Congratulations! The brunt of the setup work is complete and you're ready to use that powerful new framework to boost your Qt application. If you're using QMake, all you need is to add a simple line to your project file:
</translate>
</translate>
Line 74: Line 88:


<translate>
<translate>
<!--T:24-->
If you're using CMake, be sure to check out the helpful Extra CMake Modules for making it easy to look for and add KDE Frameworks. Check out the [[Frameworks|Frameworks Quick Start Guide]] for a simple example of using the framework or jump right into the [[Development/Tutorials|rest of Tutorials]].
If you're using CMake, be sure to check out the helpful Extra CMake Modules for making it easy to look for and add KDE Frameworks. Check out the [[Frameworks|Frameworks Quick Start Guide]] for a simple example of using the framework or jump right into the [[Development/Tutorials|rest of Tutorials]].
</translate>
</translate>

Revision as of 18:42, 17 October 2019

Other languages:

Contrary to popular misconception, you don't have to install all of "KDE" (you can't download a community) or a monolithic kdelibs (no longer exists) just to develop KDE software. That's especially true if you just want to use just a few KDE Frameworks for your Qt project. You don't even need to compile anything at all! Except for your own project, of course. Granted, there are a few ways to go about using KDE libraries for your application so this page lists some of them, depending on your situation or need.

Installation

Prerequisites

This guide focuses mainly on setting up KDE Frameworks. Whether you build it from source or use your distro's packages, you will need a few other pieces to use them.

  • CMake - as of 2019, the required version is CMake 3.5
  • Compiler - On Linux, GCC 4.8 and Clang 3.3 are required, enabling support for C++11 features

Easy as pie: Package manager

The easiest and safest way to use a KDE framework is to install it (or its development package) from your Linux distribution's package manager. Say you want to add some syntax highlighting to your Qt text editing widget. On KDE Neon or Kubuntu or Debian, this one line sets it all up:

sudo apt install libkf5syntaxhighlighting-dev

That's it! You can then proceed to actually using the framework in your app. Of course, this presumes that your distro has a more or less recent version of the framework in its repository or that you're fine with not using the latest. If not, proceed to Plan B.

Make it so!

KDE Frameworks is released on a monthly basis to ensure that developers will always have access to bug fixes or new features as soon as possible. The Plasma workspaces and KDE applications have their own release schedules as well. Sometimes, however, distros don't always provide the latest version of KDE software that you might need. If that's the case, you might have to compile the framework from the source. Not to worry, it's not as daunting or complicated as in the past.

Step 1: Download the framework

Download the latest version of the framework either from tarballs or from Git. Note that Git master will always have the latest version of the code and may not be stable, so be sure to checkout the stable tag for the release you need.

git clone https://anongit.kde.org/kwidgetsaddons.git

Step 2: Build it!

Go into the directory of the downloaded/cloned framework and issue the following commands:

mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME
make install

Presuming you have the proper dependencies installed (you'll have to consult your distro's package manager), this should end in a successful build that's ready to install. Note that KDE software use an "out-of-source build" structure to make things cleaner and easier to clean up if needed.

Step 3: Install

This part is usually tricky. Normally, you'd issue the make install command at this point, which you can certainly do that if you already know the CMake trick. You can also use sudo make install but that would overwrite your system-installed version of the framework without prejudice. The safest way would be to install the framework somewhere in your home directory, following the steps outlined in this tutorial. Do note you'll have to adjust some system environment variables so that your project will see the newly-installed framework.

Use the source

KDE does have a tool that specializes in automating the above. It might be overkill for one-off use of frameworks but if you find yourself getting attached to more and more KDE Frameworks (which is definitely a good thing), you might want to give the kdesrc_build tool a good try. It's especially useful for developers interested in leveling up to become KDE rockstars.

Using KDE Frameworks

Made it this far? Congratulations! The brunt of the setup work is complete and you're ready to use that powerful new framework to boost your Qt application. If you're using QMake, all you need is to add a simple line to your project file:

QT += KWidgetsAddons

If you're using CMake, be sure to check out the helpful Extra CMake Modules for making it easy to look for and add KDE Frameworks. Check out the Frameworks Quick Start Guide for a simple example of using the framework or jump right into the rest of Tutorials.