[racket] How to compile C libraries that use Cairo?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Nov 24 12:07:37 EST 2013

This is great! I have been tempted to just compile the libraries for
you, but taking advantage of your interest has paid off. Now, at least
two of us know how this works, and you've written much better
instructions.

As far as I can tell, your instructions don't mention the patches in
"racket/src/mac/README.txt". Did you apply those patches or skip them?


Most of the libraries seem to work on my 10.6 machine. The exceptions
are libgmp and libmpfr, but those don't need new builds, right?

It looks like these are the three new libraries for the
"draw-x86_64-macosx" package: "libfontconfig.1", "libexpat.1", and
"libfreetype.6". Is that right?


FWIW, for 64-bit Mac OS X, we only try to support 10.6 and later.

For 32-bit Intel Mac OS X, we have been supporting 10.4 and later.
Although we can compile Racket for 10.4 on a 10.8 machine, the only way
that I've been able to compile support libraries for 10.4 is on a 10.5
machine (that I have avoided upgrading).

And then there's PPC.

I expect that I'll need to build the 32-bit versions (Intel and PPC),
and that's fine.

And then there's Windows...


Of course, you're right about "@loader_path".


I'm not sure know about upgrading. I have a request, still on my to-do
list, to upgrade the Windows libraries; if I remember correctly, that
was to get newer glib-level functionality. Otherwise, I'm inclined to
stick with the current versions, but what's your opinion?


When we have all the libraries are built, the process will be to update
the native-code packages at

 http://git.racket-lang.org/libs

and from there they also get split out into individual packages.


At Sun, 24 Nov 2013 17:18:52 +0100, Jens Axel Søgaard wrote:
> Build instructions and source files are now available here:
> 
>     https://raw.github.com/soegaard/racket-osx-libs/master/README.md
> 
> 2013/11/24 Jens Axel Søgaard <jensaxel at soegaard.net>:
> > 2013/11/17 Matthew Flatt <mflatt at cs.utah.edu>:
> >> At Sat, 16 Nov 2013 22:16:40 +0100, Jens Axel Søgaard wrote:
> >
> >> To turn "librsvg-2.2.dylib" into something that you can give other Mac
> >> users to install into their Racket "lib" directory, you'll need to
> >> adjust the references from the "librsvg-2.2.dylib" to other ".dylib"s.
> >> You'll want to use `install_name_tool` and "@executable_path/..." paths
> >> for that. Let me know if you get that far and need more hints.
> >
> > I managed to build Cairo and Poppler and get it everything working.
> > Displaying pdf-files within DrRacket works a charm. As a consequence
> > I can now use LaTeX to render formulas to pdf, converting the pdf to pict
> > and use the formulas directly in slideshows and pictures.
> >
> > Now comes the problem of distributing the relevant libraries.
> >
> > At first I thought I could build Poppler with the same version of Cairo
> > as DrRacket and simply distribute the extra binaries, but it turns out
> > that Poppler needs a libcairo with support for Freetype and FontConfig.
> >
> > The binaries below contain a tar of a set of libraries which work together.
> >
> > It was compiled on a x64 machine with OS Mavericks. I used
> >     MACOSX_DEPLOYMENT_TARGET=10.5
> > and
> >    -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk
> > during for all builds, but help to confirm that the libraries actually works
> > on other machines than my own.
> >
> > Inspired by you install-files.rkt I didn't use @executable_path
> > but used @loader_path.
> >
> > Since the original goal was a make libpoppler that were compatible
> > with Racket's libcairo, I have used version numbers of the
> > various libraries as close the Racket ones as I could.
> >
> > https://www.dropbox.com/s/hdwbm2nt0fap8bt/soegaard-libs.tar.gz
> >
> > To test these binaries, place them in the result of
> >
> >     > (require setup/dirs)
> >     > (find-lib-dir)
> >     #<path:/Users/soegaard/racket-nov-24/racket/racket/lib>
> >
> > To see a pdf-file inside DrRacket run:
> >
> > #lang racket
> > (require (planet gcr/pdf-render:2:=2) pict)
> > (define pdf-file "/Users/soegaard/Downloads/x.pdf")
> > (if (file-exists? pdf-file)
> >     (pict->bitmap (page->pict pdf-file))
> >     "not found")
> >
> > Note that (page->pict pdf-file) displays an empty snip.
> >
> > The reason is that DrRacket normally calls the pict not
> > with a real cairo context, but with a record-dc% and the
> > recorded operations are then later replayed. Since
> > the pict from (page->pict pdf-file) calls libpoppler that
> > calls libcairo, these operations aren't recorded.
> >
> > A few questions:
> >
> >   1. Do these binaries work for others than me?
> >   2. Is it worth looking into getting these binaries working on pre
> > x64 hardware?
> >   3. Should I make a set of binaries with new versions of all
> > libraries in question?
> >      (While I can remember how things work)
> >
> > I will write up a detailed description of how I build them and put the 
> sources
> > on GitHub.
> >
> > --
> > Jens Axel Søgaard
> 
> 
> 
> -- 
> --
> Jens Axel Søgaard


Posted on the users mailing list.