Difference between revisions of "Compiling Inkscape"

From Inkscape Wiki
Jump to navigation Jump to search
m
(add internal lib2geom instructions)
 
(72 intermediate revisions by 27 users not shown)
Line 1: Line 1:
Hopefully, Inkscape will compile right out of the box. If it doesn't, well that's what this page is for.
<mark>Hopefully, Inkscape will compile right out of the box, according to the 'Getting Started' instructions on https://inkscape.org/develop/getting-started/ . If it doesn't, well that's what this page is for. </mark>


Jot down notes, questions, findings, tips, etc. here on things you run into.  It's a good idea to
make mention of what version of the code you're trying to compile, the distribution you're running,
and other such information that might be pertinent.


If legitimate bugs are found or patches developed, please move them to the tracker at Sourceforge
<mark> '''If you've come here without reading the Getting Started page, [https://inkscape.org/develop/getting-started/ please do so first], as it mentions some important things that this page does not.'''
rather than inlining them here. 
</mark>


= Notes =
Inkscape needs automake1.7 or automake1.8 to compile NOT automake1.9 it has a bug ( link: http://sourceforge.net/mailarchive/message.php?msg_id=10288631 ) that prevents compiling of Inkscape. If you have already tried to do a $ make with automake1.9 then $ ./autogen.sh from your inkscape-cvs dir and proceed as normal.


Jot down notes, questions, findings, tips, etc. here on things you run into. It's a good idea to make mention of what version of the code you're trying to compile, the distribution you're running, and other such information that might be pertinent.
If legitimate bugs are found or patches developed, please move them to the [https://inkscape.org/contribute/report-bugs/ tracker] rather than inlining them here. 
== Notes ==
Please use CMake instead of Automake for Inkscape 0.92 onwards.
CMake is a crossplatform makefile generator similar to autotools. It tests dependencies and creates makefiles to be used with make.
Please see the [[CMake]] wiki page.
== OS & Distribution Specific ==


= OS &amp; Distribution Specific =
* '''Linux'''
* '''Linux'''
** [[CompilingFedora|Fedora]]
** [[CompilingUbuntu|Ubuntu]]
** [[CompilingGentoo|Gentoo]]
** [[CompilingDebian|Debian]]
** [[CompilingYellowDog|Yellow Dog]]
** [[CompilingSuse|Suse]]
** [[CompilingSlackware|Slackware]]
** [[CompilingSlackware|Slackware]]
** [[CompilingYoper|Yoper]]
** [[CompilingMandrake|Mandrakelinux]]
* [[CompilingMacOsX|Mac OS X]]
* [[CompilingMacOsX|Mac OS X]]
* [[Win32Port|Windows]]
* [[Compiling Inkscape on Windows|Windows]]
* [[CompilingSPARC|SPARC]]
* [[Compiling Inkscape on Chrome OS|Chrome OS]]
* [[CompilingSunSolaris|Sun Solaris]]
* '''Cross-compiling'''
* [[CompilingStatic|Static Compiles]]
** [[CrossCompilingOsX|For OS X (from Linux)]]
** [[CrossCompilingWindows|For Windows (from Linux)]]


 
== Package Config (pkg-config) ==
= Package Config (pkg-config) =


If you must compile and install any of these from source, you may find an error like this when trying to
If you must compile and install any of these from source, you may find an error like this when trying to
compile them or Inkscape itself:
compile them or Inkscape itself:
 
<pre>
checking for gtk+-2.0 >= 2.0.0  libxml-2.0 >= 2-2.4.24  sigc++-1.2  gtkmm-2.0... Package gtkmm-2.0 was not found in the pkg-config search path.
checking for gtk+-2.0 >= 2.0.0  libxml-2.0 >= 2-2.4.24  sigc++-1.2  gtkmm-2.0... Package gtkmm-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-2.0.pc'
Perhaps you should add the directory containing `gtkmm-2.0.pc'
to the PKG_CONFIG_PATH environment variable
to the PKG_CONFIG_PATH environment variable
No package 'gtkmm-2.0' found
No package 'gtkmm-2.0' found
</pre>


A solution is to set the PKG_CONFIG_PATH variable as so:
A solution is to set the PKG_CONFIG_PATH variable as so:
* for Bash: <code>export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig</code>
* for csh: <code>setenv PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/usr/lib/pkgconfig</code>


for bash:
A good place to put this line is in your .bashrc or .cshrc file.
    export PKG_CONFIG_PATH=/usr/local/bin/pkgconfig:/usr/lib/pkgconfig
for csh:
    setenv PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/usr/lib/pkgconfig
 
A good place to put this line is in your .bashrc or .cshrc file
 
 
= Getting and Installing Source packages =
 
If your distro does not have some packages available (like many don't, ie, Fedora Core 2), you must often download
source packages and build and install them yourself.  Actually this is not that hard, and is similar to
doing a Gentoo 'emerge.'
 
* Usually you download a file with a name like somepackage-1.0.tar.gz.  Unpack it with
 
    $ tar zxf somepackage-1.0.tar.gz
    or
    $ tar jxf somepackage-1.0.tar.bz2
 
* Then 'cd' into the new directory.
 
* Configure it with the command:
 
    $ ./configure
 
* Build it with:
 
    $ make
 
* As the 'root' user,  install it with:
 
    $ make install
 
== Boehm-GC ==
 
Source: http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc6.4.tar.gz
 
 
[Note that for old 0.40CVS development versions we used the C++ version of gc, so you need to compile it with the --enable-cplusplus; we didn't include that version in any of the official releases though.]
 
Also, if searching for a package for GC, the name of it is sometimes:
 
* gc
* libgc
* libgc-devel
* boehm-gc  (on Gentoo)
 
 
== libSigc++ ==
 
Source: http://sourceforge.net/project/showfiles.php?group_id=1970&package_id=76644
 
With this file, and for GlibMM and GtkMM below, it is usually desirable for us developers to
build this C++ library statically.  This removes a dependency that might be difficult for an
end-user during installation.  Configure it with:
 
    ./configure --enable-static --disable-shared
 
 
== GlibMM ==
 
Source: http://ftp.gnome.org/pub/GNOME/sources/glibmm/2.4/
 
== GtkMM ==
 
Source: http://ftp.gnome.org/pub/GNOME/sources/gtkmm/2.4/
 


== Dependencies ==


If your distro does not have some packages available (like many don't, ie, Fedora Core 2), you must often download and build source packages and/or install them yourself. See [[Tracking Dependencies]].


== Developer Compilation ==


Plain vanilla compilation is done as documented in INSTALL.


= Developer Compilation =
Now, you should use [[CMake]] to compile Inkscape:
<pre>
mkdir build
cd build
cmake ..
make
</pre>


Plain vanilla compilation is done as documented in INSTALL; ./autogen.sh (optionally); ./configure; make; su && make test; make install (optional).  See INSTALL for more on that.
For old versions of inkscape before 0.92, you can still use autoconf:
<pre>
./autogen.sh # optionally
./configure
make
</pre>


But if you're going to be doing a lot of development, there's some tricks and techniques you should know,
Then, to run tests and install Inkscape, you may do:
to get best results.
<pre>
make check
sudo make install || su -c "make install"
</pre>


#  Turn off optimization
See INSTALL.md for more on that.
#  Use ccache for faster compilation
#  Set up a separate build directory (nice for testing both gcc and g++, or cross compiling)
#  Use the -j N flag to optimize for the number of processors in your machine, with N = 1 + no. proc's


Example:  Setting up both gcc and g++ build environments (in separate tree), and using ccache for faster
But if you're going to be doing a lot of development, there's some tricks and techniques you should know, to get best results.
compilations on a dual-processor machine, with no optimization, assuming /bin/bash:


mkdir build-gcc build-g++
# Turn off optimization.
cvs checkout inkscape
# Use ccache for faster compilation.
cd inkscape
# Set up a separate build directory (nice for testing both gcc and g++, or cross-compiling).
libtoolize --copy --force
# Use ninja or the make -j N flag to increment the number of threads available to make, with N = 1 + number of processors.
./autogen.sh
cd ../build-gcc
CFLAGS='-g -O0 -Wall' CC='ccache gcc' ../inkscape/configure
cd ../build-g++
CXXFLAGS='-g -O0 -Wall' CXX='ccache g++' ../inkscape/configure
cd build-gcc && make -j 3
cd build-g++ && make -j 3


Example:  Setting up the build environment (in separate tree), and using ccache for faster
compilations on a dual-processor machine, with no optimization and full debug symbols, assuming /bin/bash:
<pre>
mkdir build
git clone --recurse-submodules https://gitlab.com/inkscape/inkscape.git
cd build
cmake ../inkscape -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Debug -G Ninja
ninja
</pre>


Turning off just optimization (which can produce strange results in debuggers):
See [[Testing Inkscape]] for information on building and executing (unit) tests.


export CC=g++
=== Internal lib2geom ===
export CXXFLAGS='-g -O0 -Wall'
If the version of Inkscape you are trying to build depends on recent lib2geom features, you'll need to add <code>-DWITH_INTERNAL_2GEOM=ON</code> to the cmake command to use the development version of lib2geom rather than the system version.
export CFLAGS='-g -O0 -Wall'
[[Category:Developer Documentation]]
./configure

Latest revision as of 18:46, 7 February 2023

Hopefully, Inkscape will compile right out of the box, according to the 'Getting Started' instructions on https://inkscape.org/develop/getting-started/ . If it doesn't, well that's what this page is for.


If you've come here without reading the Getting Started page, please do so first, as it mentions some important things that this page does not.


Jot down notes, questions, findings, tips, etc. here on things you run into. It's a good idea to make mention of what version of the code you're trying to compile, the distribution you're running, and other such information that might be pertinent.

If legitimate bugs are found or patches developed, please move them to the tracker rather than inlining them here.

Notes

Please use CMake instead of Automake for Inkscape 0.92 onwards.

CMake is a crossplatform makefile generator similar to autotools. It tests dependencies and creates makefiles to be used with make.

Please see the CMake wiki page.

OS & Distribution Specific

Package Config (pkg-config)

If you must compile and install any of these from source, you may find an error like this when trying to compile them or Inkscape itself:

checking for gtk+-2.0 >= 2.0.0  libxml-2.0 >= 2-2.4.24  sigc++-1.2  gtkmm-2.0... Package gtkmm-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtkmm-2.0' found

A solution is to set the PKG_CONFIG_PATH variable as so:

  • for Bash: export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
  • for csh: setenv PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/usr/lib/pkgconfig

A good place to put this line is in your .bashrc or .cshrc file.

Dependencies

If your distro does not have some packages available (like many don't, ie, Fedora Core 2), you must often download and build source packages and/or install them yourself. See Tracking Dependencies.

Developer Compilation

Plain vanilla compilation is done as documented in INSTALL.

Now, you should use CMake to compile Inkscape:

mkdir build
cd build
cmake ..
make

For old versions of inkscape before 0.92, you can still use autoconf:

./autogen.sh # optionally
./configure
make

Then, to run tests and install Inkscape, you may do:

make check
sudo make install || su -c "make install"

See INSTALL.md for more on that.

But if you're going to be doing a lot of development, there's some tricks and techniques you should know, to get best results.

  1. Turn off optimization.
  2. Use ccache for faster compilation.
  3. Set up a separate build directory (nice for testing both gcc and g++, or cross-compiling).
  4. Use ninja or the make -j N flag to increment the number of threads available to make, with N = 1 + number of processors.

Example: Setting up the build environment (in separate tree), and using ccache for faster compilations on a dual-processor machine, with no optimization and full debug symbols, assuming /bin/bash:

mkdir build
git clone --recurse-submodules https://gitlab.com/inkscape/inkscape.git
cd build
cmake ../inkscape -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Debug -G Ninja
ninja

See Testing Inkscape for information on building and executing (unit) tests.

Internal lib2geom

If the version of Inkscape you are trying to build depends on recent lib2geom features, you'll need to add -DWITH_INTERNAL_2GEOM=ON to the cmake command to use the development version of lib2geom rather than the system version.