Enable Cairo on Mac

102 views
Skip to first unread message

Steve Willis

unread,
May 11, 2019, 6:18:40 PM5/11/19
to fltk.general
I am trying to build FLTK 1.3.5 with Cairo support on a Mac with this configure flag:

./configure --enable-cairo


The output of make is as follows:

=== making jpeg ===

Compiling jaricom.c...

Compiling jcapimin.c...

Compiling jcapistd.c...

Compiling jcarith.c...

Compiling jccoefct.c...

Compiling jccolor.c...

Compiling jcdctmgr.c...

Compiling jchuff.c...

Compiling jcinit.c...

Compiling jcmainct.c...

Compiling jcmarker.c...

Compiling jcmaster.c...

Compiling jcomapi.c...

Compiling jcparam.c...

Compiling jcprepct.c...

Compiling jcsample.c...

Compiling jctrans.c...

Compiling jdapimin.c...

Compiling jdapistd.c...

Compiling jdarith.c...

Compiling jdatadst.c...

Compiling jdatasrc.c...

Compiling jdcoefct.c...

Compiling jdcolor.c...

Compiling jddctmgr.c...

Compiling jdhuff.c...

Compiling jdinput.c...

Compiling jdmainct.c...

Compiling jdmarker.c...

Compiling jdmaster.c...

Compiling jdmerge.c...

Compiling jdpostct.c...

Compiling jdsample.c...

Compiling jdtrans.c...

Compiling jerror.c...

Compiling jfdctflt.c...

Compiling jfdctfst.c...

Compiling jfdctint.c...

Compiling jidctflt.c...

Compiling jidctfst.c...

Compiling jidctint.c...

Compiling jmemmgr.c...

Compiling jmemnobs.c...

Compiling jquant1.c...

Compiling jquant2.c...

Compiling jutils.c...

Archiving ../lib/libfltk_jpeg.a...

=== making png ===

Compiling png.c...

Compiling pngset.c...

Compiling pngget.c...

Compiling pngrutil.c...

Compiling pngtrans.c...

Compiling pngwutil.c...

Compiling pngread.c...

Compiling pngrio.c...

Compiling pngwio.c...

Compiling pngwrite.c...

Compiling pngrtran.c...

Compiling pngwtran.c...

Compiling pngmem.c...

Compiling pngerror.c...

Compiling pngpread.c...

Archiving ../lib/libfltk_png.a...

=== making src ===

=== making cairo ===

Compiling Fl_Cairo.cxx...

/usr/bin/ar cr ../lib/libfltk_cairo.a ...

=== making fluid ===

=== making test ===

Linking cairo_test...

ld: library not found for -lcairo

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[1]: *** [cairo_test] Error 1

make: *** [all] Error 1


Do I need to pass something to configure to link cairo_test? Cairo is installed on my system from Mac Ports as recommended on the Cairo website, and works for linking regular (non-FLTK) C programs.

Ian MacArthur

unread,
May 11, 2019, 6:29:55 PM5/11/19
to fltkg...@googlegroups.com


> On 11 May 2019, at 23:17, Steve Willis <steve....@gmail.com> wrote:
>
> I am trying to build FLTK 1.3.5 with Cairo support on a Mac with this configure flag:
>
> ./configure --enable-cairo
>
>
> The output of make is as follows:
>
> === making jpeg ===


<snip make output>

It’s slightly curious that re-running configure with cairo support enabled appears to have caused the png and jpeg libs to be rebuilt, but not much of the fltk core... perhaps that is normal, but it does seem odd.

>
>
> === making src ===
>
> === making cairo ===
>
> Compiling Fl_Cairo.cxx...
>
> /usr/bin/ar cr ../lib/libfltk_cairo.a ...
>
> === making fluid ===
>
> === making test ===
>
> Linking cairo_test...
>
> ld: library not found for -lcairo
>
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
>
> make[1]: *** [cairo_test] Error 1
>
> make: *** [all] Error 1
>
>
> Do I need to pass something to configure to link cairo_test? Cairo is installed on my system from Mac Ports as recommended on the Cairo website, and works for linking regular (non-FLTK) C programs.


I’d assume that Mac Ports has put the Cairo libs and header files somewhere that fltk does not expect, so you’ll need to tell fltk where they are. Does Mac ports use an /opt tree or something? I can’t recall.

I’ve never used Mac ports, so can’t comment. I’ve never really found the need, most things just seem to build normally on my Mac anyway so...

As a result, when I’ve used Cairo it’s just been in the “normal” places and fltk has been fine with that.

Do you have pkg-config? If so, I think that will tell you have the include and lib paths for your Cairo installation are; you can then pass these to the fltk configure script by setting CFLAGS and LDFLAGS appropriately when you evoke configure, viz...


LDFLAGS=‘-L/path/to/cairo/libs/blah’ CFLAGS=‘-I/path/to/cairo/headers’ CXXFLAGS=‘-I/path/to/cairo/headers' ./configure --blah-blah-etc


Worth a shot at any rate; see how you get on. And let us know if it works!





Steve Willis

unread,
May 11, 2019, 6:48:00 PM5/11/19
to fltk.general
Thanks! Your assumptions and suggested resolution were all correct. Specifically:

$ pkg-config --cflags --libs cairo

-I/opt/local/include/cairo -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -I/opt/local/include/pixman-1 -I/opt/local/include -I/opt/local/include/ossp -I/opt/local/include/freetype2 -I/opt/local/include/libpng16 -I/opt/local/include -L/opt/local/lib -lcairo


So, using your suggestion and the above output, I tried this successfully:

$ LDFLAGS='-L/opt/local/lib' CFLAGS='-I/opt/local/include/cairo' CXXFLAGS='-I/opt/local/include/cairo' ./configure --enable-cairo


I'm not opposed to doing a more "typical" configure/make/make install cycle to install cairo on my system. I thought the Mac Ports binary was the preferred installation path, but now can't find a reference on the cairo website to support that statement.

One thing that I do find curious is that make did not fail to build the FLTK cairo support, but only the cairo test. Perhaps the configure script is using pkg-config for the former and hard-coded paths for the latter?


Greg Ercolano

unread,
May 11, 2019, 7:00:31 PM5/11/19
to fltkg...@googlegroups.com
On 5/11/19 3:47 PM, Steve Willis wrote:
> One thing that I do find curious is that make did not fail to build the FLTK cairo support,
> but only the cairo test.

Sounds like the FLTK build found the cairo include files, but not the cairo lib.

The cairo lib isn't needed until an application is actually linked,
which is why FLTK library could build, but building the test program failed,
as that has to actually link in the cairo lib. (Building FLTK's lib does not)

Ian MacArthur

unread,
May 11, 2019, 7:03:17 PM5/11/19
to fltkg...@googlegroups.com
Yes - likely that.

The other thing it might be is that, if you do not have GL paths set right, fltk still builds the GL demos, but when you run them then where the GL context ought to be you just get a box saying GL wasn’t found.

So I don’t know if the handling of Cairo is the same, I guess it might be, though probably not or why would the link stage have failed?



Reply all
Reply to author
Forward
0 new messages