Building SVN versions with CMake

This page tries to describe how to build Scribus from source.
The instructions mainly refer to building Scribus on Linux. Building on Mac OS and on Windows is not easy; you can find some explanations for Mac OS here, and for Windows here.

TL;DR (Too Long; Didn't Read)

You know what you are doing already and just want to compile Scribus via SVN, skip the introduction and go to Installing 1.5svn

Why would I Need or Want to 'Build' Scribus?

For Necessity: You are using the current stable version, but certain bugs are a problem, and you know they have been fixed since the last release.

For Science: You have heard about some new features in the development version, and you'd like to try them out.

For the World: You're considering helping out the Scribus project and want to see how it's put together to get some idea about how you can help.

'Or, for that matter, what is this 'Building' you speak of?

Expand this content if you need a little bit more background on what Building source code means. --->

When you are going to build or compile Scribus, what you have downloaded (if you have downloaded the source code) is a large collection of plain-text files (ending in '.c' or '.cpp' to denote either the C or C++ programming language respectively). The reason there are so many is that this actually makes the process of developing software easier, and allows for use of small parts repeatedly by different functions of the overall program. These plain-text files need to be converted to binary files (ending in ',o' for object files) so that your computer can use them, and the program works efficiently.

The first step is to configure your downloaded directory of files. This requires a check of your computer to make sure the compiling programs and all the other required outside resources are present and sufficiently up-to-date. Just as Scribus itself consists of these small program files, it also will use those of outside programs, like CUPS, lcms, and so on, so it needs to have on hand those plain text files to connect to these outside resources. After checking for the necessary resources, a script is being written to tell the compiler how to go about building Scribus. The process will fail if you are missing something, and cmake will give you error messages.

The Scribus Team requires the use of CMake for this configuring process. It is quick, easy to use, and easy for the developers to write for – even CMake needs instructions. You can also pass to CMake several special parameters for your particular Computer setup, for example, where you want Scribus to be installed.

Next, the actual 'build' process is done with a program called make. To start the process you simply enter make in a command line. That's it. You do not need to have root privileges to compile, and it is generally recommended that do not compile as root (one reason for this is that, by creating a number of files under root's name, you then interfere with subsequent updating from SVN). Compiling takes up a good part of your computer's resources, especially your processor(s), so you will find its performance rather sluggish while compiling is going on. Consequently, many find that compiling is best done by starting make and then walking away from the PC to let it do its work.

Finally, you need to install, done with the command make install. If you are going to install in the default location, you will need to have root privileges. On most Linux distros this can easily be done with the su command (after which you need root's password), or with sudo, entered as sudo make install. You can run cmake with a command that can install Scribus in a directory for which you have write privileges, and therefore do not need to be root.

For this help, and other advice, continue reading the following sections.

Fear is the mind Killer...

"Do not fear building Scribus from source" ~Paul Muad'dib Atreides

There is nothing to fear here, building Scribus yourself is not as hard as it sounds. This page can teach a beginner many things at once: starting with beginning to comprehend the internals of Scribus to appreciating the Command Line shell and how to invoke commands through it. Learn how to install software libraries (components that Scribus utilizes) and go so far as to modify source code through applying patches. This exposure will help increase your skill set to work on most all platforms and widen your knowledge of software creation and maintenance.

1st: Download latest snapshot with Subversion

Subversion is the versioning control system used for Scribus. This allows multiple developers to hack on Scribus source code simultaneously. Check the Subversion page for further details on how to use this tool. Make sure you have svn installed. You don't need to learn all subversion commands and options: "svn co" and "svn up" might suffice, see below for examples.

You should create a directory in which the Scribus source code will be downloaded. Then change to that directory, and once you are there, you can download the source code with a simple command. You have to choose which branch you will download, as shown in the table below:

When subversion finishes downloading, you will find the source code in ~/scribussource/Scribus

If you have the source code and you want to update it to the latest version:

cd ~/scribussource/Scribus
svn up

2nd: Install methods: Package Manager, Source, Out-of-Source Build

Essential tools

Before going further, we must understand that in order for anything to get built, tools need to exist. In modern OS's especially Linux many of these are build tools arrive already bundled. If they aren't for some reason you will need to install them manually (see package manager)

gcc

gcc-c++

cmake (version ≥ 2.8.9)

subversion – if you're going to compile, you might as well get the latest Scribus updates

There are several option for installation.

Package Manager: (difficulty: easy) Does a lot of the heavy lifiting by installing all the components you specify

Package Managers

Note: many Linux distros have their own Package Managers i.e. Debian has apt, Fedora and Centos have yum, Redhat uses rpm etc... On Mac OS X there are several choices, most popular are Macports and Homebrew. In general, by utilizing the installed package manager we can streamline the installations through easy one liners which will automate the install. We do this by invoking the following pattern:

Specific Dependencies

Dependencies are considered to be 3rd party software libraries or other altogether unique software projects that are have components that are needed to build a specific project from. When we want to build Scribus we need to make sure that we have all the dependencies fulfilled or else it will complain to us about missing components or obsolete ones. The following section assumes you need to manually install dependencies. Here are the list of package names that will be needed to be installed before attempting to build Scribus. Each major version of Scribus will require different dependencies.

On Linux, for each item you have to install both the main package and the development package (for example: cairo and cairo-devel, pixman and pixman-devel, and so on). Some packages should be already installed (for example, Cairo or CUPS).

Getting and installing Qt5

Starting with rev. 19790 (4 February 2015), Qt 5.2 or later is required.

If Qt5 is not present on your system, you have to install or build it.

You can download Qt5 from http://qt-project.org/downloads. Binary installers are available for Windows, Mac OS X and Linux. For Linux, if your distribution provides the latest Qt5, you can install it from its repositories (details for some distributions are listed below).

Also available is the source code, in case you want to build Qt5 yourself, or if an installer is not available for your operating system.

If you're using the Qt installer on Linux, make sure to make the file qt-opensource-linux-x**-5.*.*.run executable. You can do this via your chosen UI or the command line. The latter requires the following commands:

chmode +x /path/to/qt-opensource-linux-x**-5.*.*.run

To start the installation process, use the cd command to move into the installer's directory.

Next, run the following command:

./qt-opensource-linux-x**-5.*.*.run

If run without root privileges, the installer will suggest /home/username/Qt5.* as the installation directory. That's fine if you only want to test Scribus 1.5.x. If you also want to test the latest versions of other programmes using Qt5, you should install Qt5 with root privileges.

If you have Qt4 and Qt5 installed, and/or cmake does not find Qt5, you need to specify its location with the build option -DQT_PREFIX="path-to-Qt5" (for example: -DQT_PREFIX="/home/user/Qt/5.1.1/gcc/")

Additional dependencies for some graphics formats

In 1.5.0+, there are a number of vector and bitmap graphics formats which can now be imported into Scribus. Some of these have particular additional dependencies.

GraphicsMagick (Optional)

You do not need GraphicsMagick to run cmake or compile 1.5.0svn, but some added import filters will be available if you have it (and cmake will detect it automatically). What Scribus needs are the following packages: graphicsmagick, graphicsmagick-devel, graphicsmagick-c++, and graphicsmagick-c++-devel.

OpenSceneGraph (Optional)

This may be available with your Linux distribution (definitely for Fedora 17 and later). You can also download and compile yourself.

Fedora

sudo yum install OpenSceneGraph OpenSceneGraph-devel

should be enough, and will get you the additional requirements of Inventor, OpenThreads, and OpenThreads-devel.

MS Publisher and WPG Importers

To build Scribus with support for MS Publisher and WPG files, you need libmspub, as well as libwpg and libwpd. Note that the minimum version for PUB import is libmspub 0.0.6, and also that you want the development packages (libwpd-devel, libwpg-devel, libmspub-devel, for example in Fedora).

Update (June 2014): Scribus is now able to import MS Publisher, MS Visio and CorelDraw documents via librevenge. See this page for details.

In addition to the above each Linux distrubution has it's own quirks to be aware of. The subsections below work to address them:

Fedora

Warning:

Please update this section

For Fedora at least, the names are as used with yum, for example:

yum install qt-devel lcms-devel libjpeg-devel libtiff-devel

and so on. On other distros the exact names may vary.

On Fedora, if you install various development packages, you have most of what you need. Exceptions seem to be cups-devel, lcms-devel, tk and tkinter, and python-imaging-devel (maybe cairo-devel). Incidentally, in Fedora 9 and later, Qt4 is loaded by default, and is labeled only qt and qt-devel.

Packages for Ubuntu

Warning:

Please update this section

To install all the required libraries and packages for Debian or Ubuntu type the following in a terminal:

sudo apt-get build-dep scribus-ng

In March 2011 the build dependencies for Scribus 1.4.0 on Debian/Ubuntu were:

If you're using Debian (or Ubuntu) you need to manually compile the SVN version, only if you want to be really really up to date.

Otherwise, you can rely on the .deb for scribus-ng in our own repositories or, if you don't find the packages for your platform (ppc for instance) you can let apt-get compile from source using the latest sources in the repositories (most of the time those will be older than the SVN ones, but you probably don't really care).

You first have to add the source line for deb-src in synaptic, then you should become root (sudo -i) and:

Build from Source

Moved from top of the page..being integrated Kunda (talk) 15:07, 29 June 2014 (CEST)
If you are compiling for the first time, don't be scared of the command line. Just copy the lines relevant to the version of Scribus you want to use, one by one on the command line.

Watch out:* Newbies should take care, that only 'make install' part has to be done as a root. Rest of the part, like downloading and compiling can be done easily as a normal users.You can install as a user, however, if you are installing into a directory you have write permission for. See the -DCMAKE_INSTALL_PREFIX command below.
* And if you already have a version of Scribus on your system, don't forget to use the option WANT_VERSIONING=1. You can specify this option as -DWANT_VERSIONING=1.

Take as an example this following set of commands which are geared towards the Linux environment. Here we see a case in which there is a downloading of the Scribus development version (1.5, not yet stable), building it and then installing it. Note that this assumes that the environment has been prepared previously with all the dependencies installed.

Recently moved from top of page. Still fine tuning how to represent this.

-DWANT_VERSIONING=1: Sets the build to use the VERSION setting as a suffix for the install directories and the binary. Eg, the binary could be scribus-1.3.5svn. This should mean that you can install multiple versions with the same prefix with no clashes.

-DWANT_DEBUG=1: Sets the build to be a debug release and use -O0 -g3, instead of -O2 (This is the default for now, and cannot be turned off unless you edit the CMakeFiles.txt file).

-DWANT_CAIRO=1: Makes CMake search for cairo and build with cairo instead of LibArt_LGPL. cairo is the primary supported option for 1.3.5+. (DEPRECATED)

-DWANT_LIBART=1 (not available in 1.3.5, default in 1.3.3.x): Makes CMake search for and build with LibArt_LGPL instead of cairo.

-DWANT_QTARTHUR=1: In 1.3.5, uses the QT4 ARTHUR rendering library. This is an alternative to CAIRO.

-DWANT_HUNSPELL=1: This will enable the new (as of 1.4.2) hunspell-based spell checking capabilities across *all* platforms.

If you have several version of QT installed or QT is installed in a non standard location you'll have to tell cmake where to find it by setting -DQT_QMAKE_EXECUTABLE

Out-of-Source-Builds

One of the advantages of CMake is that you can do an out-of-source build. What is this? It enables you to build the application without writing anything at all to the directory where the Scribus source is. This means your source tree is clean, always. Its easier and faster to update, and you can build multiple targets out-of-source from the same source tree. Cool!

To do an out-of-source build, you need a new directory to build in.
Say you have the source files in:

More CMake Options

Continuing on to the build stage

Once this has successfully completed, simply run make && make install.

The CMake based build system is very new to Scribus and it will change and it will need improving. Please report issues on our mailing list or bugtracker.

There is a long todo list for this build system including, but not limited to:

Checking it works across distributions

Checking it works across various flavours of UNIX

Checking it works on 64 bit distros

Add Win32 and Mac OSX support

Making a tarball for distribution

To make a tarball for distribution, the old way would be to make dist. The new way is to run make package_source or /path/to/cpack -G TBZ2 --config CPackSourceConfig.cmake to give you a bundle of the source. With cmake 2.4.1 there is only support for a gzip tar.gz however a bzip2 tar.bz2 is possible with later versions of cmake.

Notes For Packagers

If you package Scribus for a distribution keep in mind the issue of the install prefix versus temporary install directory prefix. The following seems to work well for Debian packaging: