Inkscape Devlibs are a bundle of libraries and tools used to compile Inkscape. It is hosted in a Launchpad repository. Here's some information for those who need to maintain them and rebuild all or part of the libraries.
What you need to start
- Install the TDM-GCC build of MinGW into c:\mingw (or any other folder). This is the compiler.
- Install MSYS. This is the Unix-like build environment including a shell. When you run the MSYS installer, at the end it will ask you if you have MinGW installed and if so, where. Specify the directory where you installed MinGW.
- Check out the current devlibs into C:\devlibs from Launchpad repository (see Win32Port).
- Download sources for the libraries you want to build. Released versions are recommended, not snapshots.
- Create an empty directory C:\devlibs-update. This is where the resulting compiled libraries will be placed. When you succeed, you'll have to copy them to c:\devlibs before recompiling Inkscape, so it can use the new libs.
Updating the C part of devlibs
The C part of the GTK stack can be directly copied from official development bundles. Do not copy unneeded stuff like .lib, .def, static libraries, examples or documentation.
Use MSYS and this configure command. Tested with GC 7.1. Threading support does not work: GC 6.8 compiles but causes a segfault on startup, while GC 7.1 doesn't compile.
$ ./configure --enable-large-config --disable-shared --disable-threads --prefix=/c/devlibs-update
Conflict between gc.h and MagickCore.h
ImageMagick defines _DLL in its pkg-config file to mark its API as imported from DLLs. However, the same symbol is also used by libgc, and we currently link it as a static library. To solve this conflict, two things were done:
- The bit that defines GC_DLL when _DLL is defined was removed.
- The pkg-config file was changed to define _MAGICKDLL_ instead of _DLL - this define is also supported in the MagickCore.h header.
- Download and unzip a release of pixman and cairo from cairographics.org.
- Run MSYS, and in its shell window, give the following commands:
$ export PKG_CONFIG_PATH=/c/devlibs-update/lib/pkgconfig:/c/devlibs/lib/pkgconfig $ PATH="/c/devlibs-update/bin:$PATH:/c/devlibs/bin" $ PATH=$PATH:/c/devlibs/perl/bin $ export LDFLAGS="-L/c/devlibs/lib -lpthreadGC2"
- cd to pixman source dir and do:
$ CPPFLAGS="-I/c/devlibs/include" CXXFLAGS="-O2" ./configure --prefix=/c/devlibs-update $ make $ make install
- then cd to the cairo source dir and do the same 3 commands
Done! Now in c:\devlibs-update\bin you will find the new libpixman-1-0.dll and libcairo-2.dll.
The same or similar procedure should work for other C libs.
Rebuilding the gtkmm stack
The C++ libraries 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.
- Install Doxygen: gtkmm wants it, otherwise it won't build.
- Run MSYS. Set up paths the following way. The object of this is to build e.g. gtkmm using the glibmm you have just built.
$ export PKG_CONFIG_PATH=/c/devlibs-update/lib/pkgconfig:/c/devlibs/lib/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.
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.
- 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. The header in devlibs has this modification applied.
- 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).
- 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 needs the Freetype2 treatment. Additionally, the version of libtool it uses is 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.
Generating libboost_python for py2geom
Unfortunately, our version of Boost (1.34) does not support our gcc version. So you cannot follow these instructions at this moment. We have to upgrade our Boost version to 1.37 or higher to be able to build it with our gcc... See the bug report here. I have uploaded my old libboost_python binaries to devlibs, built using MinGW 4.2.1
This concerns generating lib\libboost_python.a and lib\libboost_python.dll, required for building and using py2geom (lib2geom's python bindings). I have followed the procedure described by Boost.
- download Boost's source (not the latest Boost version, but the Boost version that is included in the devlibs!)
- figure out how to get the bjam build program.
- go to the commandline and to the root of the Boost you downloaded (in my case c:\boost, and make sure gcc is in the path (run Inkscape's mingwenv.bat)
C:\Boost> bjam --with-python --toolset=gcc
- Boost will build a variety of different libboost_python binaries in the "bin.v2" directory. For py2geom, we want the dynamically linked library. The files we want are located in bin.v2\libs\python\build\gcc-mingw-4.2.1\release. Copy "libboost_python-mgw42-1_34_1.a" and "libboost_python-mgw42-1_34_1.dll" to devlibs\lib, and rename them to libboost_python.a and libboost_python.dll.
- Commit to bzr and you are done!