Difference between revisions of "CompilingStatic"

From Inkscape Wiki
Jump to navigation Jump to search
(removed - outdated (and more or less superseded by the AppImage build))
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
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.
 
 
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+ (this 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+ (this requires a final "make install-lib")
 
* libxml 2.0+
 
* libgc 6.4+ (since some distros don't have this yet.  In 6.3, I had to 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", and you'll also have to edit Makefile to drop "demos" and "tests", and modules[[/Makefile]] to remove "input" from SUBDIRS.  Also seems to need -lz added after -lm everywhere in the gdk-pixbuf directory's Makefile for dealing with the static libpng.)
 
 
Remaining libraries to build statically:
 
* 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. murrayc.)
 
* glibmm 2.4+ (because of C++ bindings)
 
* gtkmm 2.4+ (because of C++ bindings.  edit Makefile to remove "examples", "demos", and "tests" from SUBDIRS. You can also use --disable-examples and --disable demos, which are meant to speed things up. murrayc)
 
 
== 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:
 
# Build against the static tree you've made.  Do this by adding "--define 'ink_static_root /extra/static'" to the rpmbuild command line.
 
# 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'
 

Latest revision as of 14:52, 28 May 2019