I am looking for a way to render (some simple subset of) SVG files as bitmap
images, with minimal compilation and installation hassles, on Win/Mac/Linux
(primarily 64-bit). The solution so far has been to use ImageMagick, but this
library is considered too hairy and complex and we are looking for something
more maintainable. I tried to compile librsvg on Windows under MinGW, but
after the 20-th dependency appeared to be Python interpreter I gave up. Now I
am looking into wxsvg, at first it looked promising, the wxWidgets library
even had some (outdated) msvc project files and seemed quite self-contained.
However, now the dependencies are creeping up again. It appears that when
compiling wxsvg one can choose the renderer as either agg, libart or cairo.
The first one seems to be unmaintained and has GPL license so we could not use
it anyway. Cairo has zillion dependencies again. Libart looked promising, but
then I discovered a line in wxsvg:
It seems this is for text rendering only, but this is probably dragging in
again the whole pango and cairo. I feel a bit frustrated, the effort needed to
get some simple SVG-s rendered seems to be wildly out of sync with the
importance of this feature in our program (<0.01%). I do not know much about
SVG itself and its needs, but I know there is a Windows SDK function called
DrawText, why cannot a cross-platform library just use this function on
Windows instead of dragging in some 20-library dependency chain? Maybe I
should look for some other library?
Actually agg backend doesn't depend on pango, but it is deprecated now (as
well as libart backend).
Only cairo backend is maintained. And it doesn't have million dependencies:
only png and zlib. See cairo package at
Thanks for the response, I will try a little bit more. BTW, pkconfig under
MinGW thinks that cairo also depends on gobject, glib, pixman and freetype2.
OTOH, the readme.win32 in the cairo download says that it depends on pixman
only (apart of libpng and zlib which are indeed easy).
As it seems MinGW builds insist on more dependencies than actually needed, I
will try to build with MSVC for a change. Cairo's readme.win32 also contains
some instructions for building pixman with MSVC. Alas, in pixman-0.24.0 there
is indeed a Makefile.win32, but this refers to a missing Makefile.win32.common
and seems to not work without it. So I am stuck again...
Ok, after some hacking and adding new MSVC projects where they were missing I
was able to compile wxsvg together with cairo and pixman as static libraries
and the Render example from http://wxsvg.sourceforge.net/using.html seems to work!
Sorry, one more related question. In Windows, I was able to build wxsvg
without pango, but what about Linux? The configure script is failing when it
does not find pango. Is this fundamental or could I somehow hack around it? I
am asking because on Windows configure under MinGW also insisted on pango, but
it came out it was actually not needed.
I will certainly need some text rendering in SVG, but surely wxWidgets and/or
cairo are also able to render text, aren't they?
Under Linux wxSVG uses pangocairo (part of pango) to render text to path.
There is no need to simply render the text but render with gradients, outline
Thanks for the answer. OK, I see pango is needed and I got it compiling in
Linux. However, there are other hairy parts. I am building a back-end library
which does not have any GUI at all, so I tried to eliminate some complexity by
building wxWidgets with --disable-gui. Alas, this did not compile the classes
I need, for example wxImage (adding --enable-image did not help). Without
--disable-gui it however requires gtk+, which is very hairy itself and
currently its compilation fails with some obscure errors (probably because I
am trying to build everything as static libraries).
So, is it possible to build wxWidgets without gtk+ on Linux, but still have
Actually image.cpp is stored in the sub-directory "common" and, I think, it
can be compiled without GUI. But I have no idea how to do this.
You can also try to build wxWidgets with universal GUI (--enable-universal)
instead of GTK+ GUI.
Yes, it appears with --disable-gui it would require extensive source code
hacking to get wxImage compiled. Neither did --enable-universal work, it seems
this is not really a toolkit; configure still wanted to use GTK or some other
Fortunately I discovered there is another toolkit which is smaller and self-
contained: DirectFB. It does not support many of wxWidgets features so these
have to be disable separataly (which is only good!). Finally I ended up with
./configure --enable-monolithic --with-directfb --with-themes=mono --disable-
accel --disable-popupwin ....
(altogether 87 --disable-... options), plus some minor code fixes to add
forgotten feature test #ifdef-s. Now I finally got wxsvg compiling and running
on Linux. For the record, here is the list of required libraries:
The most of people use wxWidgets to get multi-platform GUI and so it's
eventually one of few cases that you need it without GUI :)