Difference between revisions of "CompilingStatic"

From Inkscape Wiki
Jump to navigation Jump to search
Line 68: Line 68:
Remaining libraries to build statically:
Remaining libraries to build statically:
* libsigc++ 2.0+
* libsigc++ 2.0+
** Because C++ bindings ABI has changed several times, breaking Inkscape for several distros. edit Makefile to remove "docs" from SUBDIRS. (The mention of ABI breakage is a serious accusation, but the libsigc++ developers have never had any reports of it.
** The C++ bindings ABI has changed several times, breaking Inkscape for several distros. The mention of ABI breakage is a serious accusation, but the libsigc++ developers have never had any reports of it.
** Remove "docs" from SUBDIRS in Makefile.
* glibmm 2.4+
* glibmm 2.4+
** For C++ bindings
** For C++ bindings

Revision as of 20:00, 3 February 2012

Static compilation of Inkscape is one way to sidestep dependency issues. Instead of requiring the user to install the particular versions of particular libraries, we just include them in the Inkscape binary.

Warning Will Robinson, this has a cost: The inkscape binary gets BIG. But that's the tradeoff we pay for gaining this convenience. From a packager's point of view it's also a bit more work, but this page will list out the steps to take achieve it. Of course, we'll still provide "regular" libs for people who are willing to get the dependencies in order, or who won't like downloading a huge package.

Libraries

By static, we mean "all the nasty C++ and other new-fangled stuff". This is not a TRUE static binary. We are going to include only the items that we expect people may not have on their systems, and leave the more standard libraries dynamically linked.

Downloads

 wget http://www.ijg.org/files/jpegsrc.v8d.tar.gz
 wget http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc.tar.gz
 wget ftp://ftp.gtk.org/pub/gtk/v2.0/atk-1.0.3.tar.bz2
 wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.8.tar.bz2
 wget http://xorg.freedesktop.org/releases/individual/lib/libXft-2.2.0.tar.bz2
 wget http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.8.0.tar.gz
 wget http://ftp.gnome.org/pub/GNOME/sources/pango/1.29/pango-1.29.5.tar.bz2
 wget http://ftp.gnome.org/pub/GNOME/sources/libsigc++/2.2/libsigc++-2.2.10.tar.bz2
 wget http://ftp.gnome.org/pub/GNOME/sources/glibmm/2.28/glibmm-2.28.2.tar.bz2
 wget http://ftp.gnome.org/pub/GNOME/sources/gtkmm/3.0/gtkmm-3.0.1.tar.bz2
 wget http://ftp.acc.umu.se/pub/GNOME/sources/atk/1.91/atk-1.91.92.tar.bz2
 wget http://ftp.gnome.org/pub/GNOME/sources/glib/2.31/glib-2.31.14.tar.xz
 wget http://sourceware.org:/pub/libffi/libffi-3.0.10.tar.gz
 wget http://downloads.sourceforge.net/inkscape/inkscape-0.48.2.tar.bz2

Instructions

Since you probably don't want to overwrite your existing versions of these libraries, put them somewhere other than /usr or /usr/local or /opt. For these examples, I'll use /extra/static. Since they depend on eachother, order is important. To have the builds see the new static libraries, you'll need to export these variables first:

 PATH=/extra/static/bin:$PATH
 PKG_CONFIG_PATH=/extra/static/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
 CPPFLAGS=-I/extra/static/include/opt/gnome/lib/pkgconfig/
 LDFLAGS=-L/extra/static/lib
 export PATH PKG_CONFIG_PATH CPPFLAGS LDFLAGS

(SuSE Linux users, add ":/opt/gnome/lib/pkgconfig/" to PKG_CONFIG_PATH above)

Unless noted, each of the libraries is built with:

 ./configure --disable-shared  --enable-static --prefix=/extra/static
 make
 make install

List of support libraries to build statically first (they are used by the various libraries in the "Remaining" section below):

  • libpng 1.2.8+
    • Requires "cp scripts/makefile.linux Makefile" and to edit Makefile's "prefix" to /extra/static. Then a "make install-static" is all you need.
  • libjpeg 6b+
    • Requires a final "make install-lib"; recent versions perhaps not.
  • libxml 2.0+
  • libgc 6.4+
    • Some distros don't have this yet; in 6.3, edit os_dep.c, and replace the __libc_stack_end pragma/extern with "ptr_t __libc_stack_end = 0;" to get it to link. This may be fixed in new versions.

Libraries not needed, since they don't end up making anything useful. They're still listed here to retain their order, and to keep their weird configs for anyone else to play with in the future if pango can be convinced to work:

  • libexpat 1.95+
  • glib 2.0+
  • atk 1.0+
  • freetype 2.0+
  • xft 2.1+
  • fontconfig 2.2+
    • Remove "doc" and "test" from Makefile's SUBDIRS.
  • pango 1.0+
    • Ends up not working at all when built statically.
  • gtk+ 2.4+
    • Configure with "./configure --enable-static --disable-shared --without-libtiff --disable-modules --with-included-loaders=xpm,png,bmp,jpeg --prefix=/extra/static"
    • Remove "demos" and "tests" from Makefile.
    • Remove remove "input" from SUBDIRS in modules/Makefile.
    • Needs -lz added after -lm everywhere in the gdk-pixbuf directory's Makefile for dealing with the static libpng.
    • If "_gtk_marshal_OBJECT__VOID" causes an error, edit "perf/marshalers.c" and comment out the "_gtk_marshal_OBJECT__VOID" function (it has likely already been declared).

Remaining libraries to build statically:

  • libsigc++ 2.0+
    • The C++ bindings ABI has changed several times, breaking Inkscape for several distros. The mention of ABI breakage is a serious accusation, but the libsigc++ developers have never had any reports of it.
    • Remove "docs" from SUBDIRS in Makefile.
  • glibmm 2.4+
    • For C++ bindings
  • gtkmm 2.4+
    • For C++ bindings.
    • Remove "examples", "demos", and "tests" from SUBDIRS in Makefile.
    • Use --disable-examples and --disable demos, to speed up the build process.

Inkscape

If you're just building inkscape yourself, you can finally configure and build inkscape:

 ./configure ....
 make

If you're building an RPM, you can build it with the existing inkscape.spec file. Two things need to happen:

  1. Build against the static tree you've made. Do this by adding "--define 'ink_static_root /extra/static'" to the rpmbuild command line.
  2. Disable automatic dep finding (since it doesn't work correctly for static binaries). Do this by creating ~/.rpmmacros with a line that reads "%__find_requires /path/to/script" and make that script look like this:
 #!/bin/bash
 cat >/dev/null

The resulting command line will be something along the lines of (can add "--target i686" for an i686-optimized version, too):

 rpmbuild -ta --nodeps inkscape-0.41.tar.gz --define 'ink_static_root /extra/static'

See also