Difference between revisions of "Inkscape Devlibs"

From Inkscape Wiki
Jump to navigation Jump to search
m
Line 1: Line 1:
Inkscape Devlibs are a bundle of libraries and tools used to compile Inkscape. It is hosted in a [https://launchpad.net/inkscape-devlibs Launchpad repository].
Inkscape Devlibs are a bundle of libraries and tools used to compile Inkscape. It is hosted in a [https://launchpad.net/inkscape-devlibs Launchpad repository]. Here's some information that might be useful to people that need to maintain them.


== Updating the C part of devlibs ==
== Updating the C part of devlibs ==

Revision as of 18:11, 1 February 2010

Inkscape Devlibs are a bundle of libraries and tools used to compile Inkscape. It is hosted in a Launchpad repository. Here's some information that might be useful to people that need to maintain them.

Updating the C part of devlibs

The C part of devlibs can be directly copied from official development bundles. Do not copy unneeded stuff like .lib, .def, static libraries, examples or documentation.

Rebuilding the gtkmm stack

This is a description of the process I used to build the C++ libraries present in the devlibs. --Tweenk 00:50, 1 February 2010 (UTC)

  • Install the TDM-GCC build of MinGW into c:\mingw (or any other folder)
  • Install MSYS. Choose c:\mingw as your MinGW installation directory.
  • Install Doxygen. gtkmm wants it, otherwise it won't build.
  • Download current devlibs into C:\devlibs
  • Download sources for C++ libraries. Those are: libsigc++, glibmm, cairomm, pangomm, gtkmm. We use only header-only libraries from boost, so it doesn't need to be rebuilt - just copy the headers.
  • Create an empty directory C:\devlibs-update
  • Run MSYS. Set up paths the following way. The object of this is to build gtkmm using the glibmm you have just built.
$ export PKG_CONFIG_PATH=/c/devlibs-update/lib/pkgconfig:/c/devlibs/pkgconfig
$ PATH="/c/devlibs-update/bin:$PATH:/c/devlibs/bin"
$ PATH="$PATH:/c/Program Files/Doxygen/bin"
  • For each C++ library, configure, build and install it. Do it in the following order: libsigc++, glibmm, cairomm, pangomm, gtkmm. The commands should look like this:
$ CXXFLAGS="-O2" ./configure --prefix=/c/devlibs-update
$ make
$ make install
  • pangomm, cairomm and gtkmm seem to want Freetype2, but don't use pkg-config to find it. For them, do something like this. Note that those are backticks, not apostrophes.
$ FT2_CFLAGS=`pkg-config --cflags freetype2`
$ FT2_LIBS=`pkg-config --libs freetype2`
$ CXXFLAGS="-O2 $FT2_CFLAGS" LDFLAGS="$FT2_LIBS" ./configure --prefix=/c/devlibs-update
  • giomm (which is part of glibmm) has a defective main header which includes Unix-specific stuff that is not built on Windows. Comment out the following three includes in C:\devlibs-update\include\giomm-2.4\giomm.h. Otherwise gtkmm will not build.
#include <giomm/desktopappinfo.h>
#include <giomm/unixinputstream.h>
#include <giomm/unixoutputstream.h>
  • Prune C:\devlibs-update from unneeded stuff. In particular, you don't need static libraries, libtool files (.la), documentation and example programs. Note however that you DO need import libraries. They end with .dll.a - don't confuse them with static libraries that end with .a.
  • Copy the contents of C:\devlibs-update to C:\devlibs and enjoy.

Rebuilding other C++ libraries

Inkscape currently uses two non-gtkmm C++ libraries: Poppler and Magick++ (part of ImageMagick). There are currently problems with Poppler later than 0.12.1, see bug 487038 for status.

Poppler

Follow the procedure for the gtkmm stack outlines above, with the following modifications:

  • Ensure that you have libtiff, libpng and libjpeg development files matching the versions supplied by GTK. They can be downloaded from the GTK+ Windows binaries page, but should also be included in Devlibs.
  • Poppler complains that it wants libopenjpeg for JPEG2000 support. I have not been successful in building it correctly with MinGW, however.
  • libjpeg headers are broken - they define types that have conflicting definitions in basetsd.h and rpcndr.h (part of Windows API). To fix this, do two things. Both those modifications should be in Devlibs, but I'm documenting them here just in case.
    • Modify jmorecfg.h at line 162 - remove the final underscore. Apparently the include guards differ between the MS-supplied Win32 headers and the MinGW-supplied ones.
#ifndef _BASETSD_H
    • Comment out line 52 of c:\tdm-gcc\include\rpcndr.h
    • /*typedef unsigned char boolean;*/
  • You need to add Perl you PATH (for glib-mkenums).
$ PATH="$PATH:/c/devlibs/perl/bin"
  • Poppler doesn't use pkg-config. You need to explicitly pass it some flags, including those for freetype2. You also need to tell configure you want the internal headers, which Inkscape uses at the moment (but shouldn't: see bug 254849).
$ FT2_CFLAGS=`pkg-config --cflags freetype2`
$ FT2_LIBS=`pkg-config --libs freetype2`
$ CXXFLAGS="-O2" CFLAGS="-O2"
  CPPFLAGS="-I/c/devlibs-update/include -I/c/devlibs/include $FT2_CFLAGS"
  LDFLAGS="-L/c/devibs-update/lib -L/c/devlibs/lib $FT2_LIBS
  ./configure --prefix=/c/devlibs-update --enable-xpdf-headers

ImageMagick

ImageMagick needs the usual Freetype2 treatment. Additionally, the version of libtool it uses i retarded in some way, because it can't find the compiler's libgomp. You need to specify the compiler's library dir explicitly.

$ FT2_CFLAGS=`pkg-config --cflags freetype2`
$ FT2_LIBS=`pkg-config --libs freetype2`
$ CXXFLAGS="-O2" CFLAGS="-O2"
  CPPFLAGS="-I/c/devlibs-update/include -I/c/devlibs/include $FT2_CFLAGS"
  LDFLAGS="-L/c/devibs-update/lib -L/c/devlibs/lib $FT2_LIBS
  -L/mingw/lib/gcc/mingw32/4.4.1"
  ./configure --prefix=/c/devlibs-update --disable-static --without-perl

Generating import libraries from DLLs

MinGW requires an import library to link against DLLs using -l switches. Fortunately, it's usually possible to generate it from the DLL. Here's how to do this.

  • Download the pexports utility from MinGW and unpack it somewhere into your PATH.
  • Navigate to the DLL directory and say this:
pexports some.dll > some.def
dlltool -D some.dll -d some.def -l libsome.dll.a
  • Move libsome.dll.a to the lib directory of devlibs. You have to use a name that matches the pattern lib*.dll.a. Delete the .def file that was generated as a side effect.
  • Now you can link against somelib.dll using -lsome.
  • If you rename the DLL, you'll have to regenerate the import library and relink any libraries and executables linked against that DLL.