[Mono-osx] Building libgdiplus on OS X

Alex Shulgin alexander.shulgin at yessoftware.com
Mon Jun 1 08:53:18 EDT 2009


Hi,

I had to built libgdiplus on OS X recently and must admit that this was 
quite an experience.

So I'd love to see clear instructions from developers how is one 
supposed to do that.  Also, if someone is trying to build it now or 
later this might save him some time.

Here's the summary of what finally worked for me:

* Install mono-2.4 framework.

* Download & unpack libgdiplus-2.4.tar.bz2.

* Hide mono's cairo pkgconfig file to force the use of internal cairo 
version:

$ ( cd 
/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig; sudo 
mv cairo.pc cairo.pc~ )

* Run the script below:

--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
#!/bin/sh
MONO_PREFIX=/Library/Frameworks/Mono.framework/Versions/Current
TMP_PKG_CONFIG_PREFIX=~/tmp/build/pkgconfig

mkdir -p $TMP_PKG_CONFIG_PREFIX

# Mac OS doesn't come with a fontconfig.pc ... generate one
#  (libgdiplus supports using fontconfig-config, but mac also doesn't 
ship with that)
cat <<EOF > $TMP_PKG_CONFIG_PREFIX/fontconfig.pc
prefix=/usr/X11R6
exec_prefix=\${prefix}
libdir=/usr/X11R6/lib
includedir=\${prefix}/include

Name: Fontconfig
Description: Font configuration and customization library
Version: 2.3.94
Libs: -L\${libdir} -lfontconfig -lexpat
Cflags: -I\${includedir}
EOF

# fake freetype2.pc files for Apple's libs
cat <<EOF > $TMP_PKG_CONFIG_PREFIX/freetype2.pc
prefix=/usr/X11R6
exec_prefix=\${prefix}
libdir=/usr/X11R6/lib
includedir=\${prefix}/include

Name: FreeType 2
Description: A free, high-quality, and portable font engine.
Version: 9.16.3
Requires:
Libs: -L\${libdir} -lfreetype -lz
Cflags: -I\${includedir}/freetype2 -I\${includedir}
EOF

export 
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/X11R6/lib/pkgconfig:/usr/lib/pkgconfig:$TMP_PKG_CONFIG_PREFIX

export C_INCLUDE_PATH=$MONO_PREFIX/include:$C_INCLUDE_PATH
export LIBRARY_PATH=$MONO_PREFIX/lib:$LIBRARY_PATH

./configure --prefix=$MONO_PREFIX || exit 1
make
--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--


As one can see this is far from simple ./configure; make; make install.

In fact I had to bury relatively deep into mono SVN release module to 
find out a hack is used to link with OS X freetype2 and fontconfig libs: 
http://anonsvn.mono-project.com/viewvc/trunk/release/packaging/defs/libgdiplus?view=markup 


Also, C_INCLUDE_PATH and LIBRARY_PATH should be pointed to include and 
lib directories in the current installed version of mono or you'll need 
to download and compile jpeg, png, gif & tiff libraries, etc.; or type 
in some monster like xxx_CFLAGS=... xxx_LIBS=... yyy_CFLAGS=... ./configure.

I've also tried to build libgdiplus from trunk, but couldn't get past 
configure step.

Yes, autogen.sh provided in trunk has --with-cairo=internal option (so I 
don't need to hide installed cairo.pc), but configure fails at random 
places while trying to locate dependencies (BASE_DEPENDENCIES, GTK, 
etc.).  Setting ACLOCAL_PATH to current mono installation didn't help me 
with this problem.

So above is currently the best build method I've come up with.  And it 
took me days to find out all this--not very nice indeed.

Have I missed something obvious?  Are everybody who try to build 
libgdiplus on OS X supposed to stumble upon such enormous set of problems?..

--
Regards,
Alex


More information about the Mono-osx mailing list