For 64 bit: see Inkscape Devlibs 64-bit
Inkscape Devlibs are a bundle of libraries and tools used to compile Inkscape on Windows. 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.
- 1 What you need to start
- 2 Updating the C part of devlibs
- 3 Rebuilding cairo
- 4 Rebuilding the gtkmm stack
- 5 Rebuilding other C++ libraries
- 6 Generating import libraries from DLLs
- 7 Generating libboost_python for py2geom
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.
Make sure that you are using MSYS's make inside MSYS, instead of MinGW's make. You will need a recent version of MSYS, use mingw-get to install it. (make version 3.81 works for me)
- 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
Note: as of GC 7.3, libatomic_ops needs to be downloaded separately and installed in the GC source base directory (see http://www.hboehm.info/gc/#where).
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.
Now (Inkscape 0.92+) that we compile against an external Potrace library, libpotrace needs to be maintained in the devlibs. Nothing special except that you need to provide CPPFLAGS and LDFLAGS for zlib:
$ CPPFLAGS="-I/c/devlibs/include" LDFLAGS="-L/c/devlibs/lib" ./configure --prefix /c/devlibs-update --with-libpotrace
- 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.
If you encounter a "previous declaration of 'ssize_t' was here" error when compiling, add "#define _SSIZE_T_DEFINED 1" in the config.h file in the cairo source folder. (error still present with cairo 1.12.14).
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 C++11, setup the CXXFLAGS correctly. You have to add "-std=gnu++0x" (gcc) or "-std=c++11" (clang). (note that if you have to change CXXFLAGS later on, you should add "-std=gnu++0x"!)
$ export CXXFLAGS="-std=gnu++0x -O2"
- When using DW2 exception handling, extra stuff is needed. Also, if you need to point to another compiler, use CXX and CC:
$ export LDFLAGS="-shared-libgcc" $ export CXX=g++-dw2 $ export CC=gcc-dw2
- 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
- devlibs\include\fontconfig\fontconfig.h may give a warning with C++11, change
#define FC_CACHE_SUFFIX ".cache-"FC_CACHE_VERSION #define FC_DIR_CACHE_FILE "fonts.cache-"FC_CACHE_VERSION #define FC_USER_CACHE_FILE ".fonts.cache-"FC_CACHE_VERSION
#define FC_CACHE_SUFFIX ".cache-" FC_CACHE_VERSION #define FC_DIR_CACHE_FILE "fonts.cache-" FC_CACHE_VERSION #define FC_USER_CACHE_FILE ".fonts.cache-" FC_CACHE_VERSION
C++11 wants a space between string literals.
- 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. [Apparently fixed in Glibmm-2.42.0]
#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.
- Before the enjoyment can start, it may be that some pkg-config files are misconfigured. In my case C:\devlibs\lib\pkgconfig\gtkmm-2.4.pc had to be modified, 1st to include glibmm-2.4, and 2nd the version number comparisons had to be dropped (possibly because of old version of pkg-config.exe?). I had to correct the Requires: lines as follows:
Requires: glibmm-2.4 atkmm-1.6 giomm-2.4 pangomm-1.4 gtk+-2.0 gdkmm-2.4
Requires: cairomm-1.0 giomm-2.4 >= 2.27.93 pangomm-1.4 >= 2.27.1 gtk+-2.0 >= 2.24.0
- For TDM-GCC 4.8.1, I have to delete devlibs/include/pthread.h because it is already supplied by the compiler and it will result in bad errors. windows.h is included by the devlibs/include/pthread.h, and fouls the complete namespace. (So you will see many name clashes, for example vpsc::Rectangle will clash if the namespace vpsc is not mentioned.
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).
- You need to tell configure you want the internal headers, which Inkscape uses at the moment (but shouldn't: see bug 254849).
$ CXXFLAGS="-O2" CFLAGS="-O2" CPPFLAGS="-I/c/devlibs-update/include -I/c/devlibs/include" LDFLAGS="-L/c/devibs-update/lib -L/c/devlibs/lib ./configure --prefix=/c/devlibs-update --enable-xpdf-headers
- In case compilation fails with a "GetFileSizeEx was not declared in this scope" error, set the WINVER value (in c:\tdm-gcc\include\windef.h) to 0x0501 (for Windows XP) or more.
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!