For anyone who has these issues, I eventually recognized that the issue had
to do with the fact the mine cairo was not being compiled with freetype
support. I had to recompile cairo with --enable-ft=yes.

Also removed the setting of the CAIRO_LIBS and CAIRO_CLAGS environment
variables in my ~/.bashrc as that was likely unnecessary step as set due to
confusion.

After doing this, running install.packages(Cairo) worked. Hope this helps
anyone having this issue.







On Tue, Apr 29, 2014 at 9:55 AM, Fong Chun Chan <fongchunchan@gmail.com>wrote:

> Hi Peter,
>
> Unfortunately neither of the modifications to the LIB flag worked. I tried:
>
> export CAIRO_LIBS='-L${HOME}/usr/local/lib -lcairo'
>
> This actually gave me an error like this:
>
> .....
> configure: CAIRO_CFLAGS=-I/home/fong/usr/local/include/cairo
> checking if R was compiled with the RConn patch... no
> checking cairo.h usability... yes
> checking cairo.h presence... yes
> checking for cairo.h... yes
> checking for PNG support in Cairo... yes
> checking for ATS font support in Cairo... no
> configure: CAIRO_LIBS=-L${HOME}/usr/local/lib -lcairo
> checking for library containing deflate... none required
> checking whether Cairo programs can be compiled... yes
> checking whether cairo_image_surface_get_format is declared... no
> checking for FreeType support in cairo... yes
> checking whether FreeType needs additional flags... yes
> checking whether pkg-config knows about fontconfig or freetype2... yes
> checking whether additional flags work... no
> configure: error: Cannot use cairo-ft backend, although cairo claims it is
> working. Please check your caito installation and/or update cairo if
> necessary or set CAIRO_CFLAGS/CAIRO_LIBS accordingly.
>  ERROR: configuration failed for package 'Cairo'
> * removing '/home/fong/usr/local/lib64/R/library/Cairo'
> * restoring previous '/home/fong/usr/local/lib64/R/library/Cairo'
>
> I then tried to modify the CAIRO_LIBS like this:
>
> export CAIRO_LIBS=-I${HOME}/usr/local/lib/libcairo.so
>
> And this gave me this error:
>
> .....
> configure: CAIRO_CFLAGS=-I/home/fong/usr/local/include/cairo
> checking if R was compiled with the RConn patch... no
>  checking cairo.h usability... yes
> checking cairo.h presence... yes
> checking for cairo.h... yes
> checking for PNG support in Cairo... yes
> checking for ATS font support in Cairo... no
> configure: CAIRO_LIBS=-I/home/fong/usr/local/lib/libcairo.so
> checking for library containing deflate... no
> checking whether Cairo programs can be compiled... configure: error:
> Cannot compile a simple Cairo program. See config.log for details.
> ERROR: configuration failed for package 'Cairo'
> * removing '/home/fong/usr/local/lib64/R/library/Cairo'
> * restoring previous '/home/fong/usr/local/lib64/R/library/Cairo'
>
>  My pkg-config command:
>
> >> pkg-config --cflags --libs cairo -I/home/fong/usr/local/include/cairo
> -I/home/fong/usr/local/include/pixman-1
> -I/home/fong/usr/local/include/freetype2
> -I/home/fong/usr/local/include/libpng16 -L/home/fong/usr/local/lib -lcairo
>
> I appear to be missing glib and libdrm which you have. Perhaps I should
> try to install that?
>
> Thanks,
>
>
>
> On Mon, Apr 28, 2014 at 9:34 PM, Peter Langfelder <
> peter.langfelder@gmail.com> wrote:
>
>> I **think** the linker is missing a directive to actually link in the
>> cairo library. Try adding -lcairo to the LIB flags, something like
>>
>> export CAIRO_LIBS='-L${HOME}/usr/local/lib -lcairo'
>>
>> or simply
>>
>> export CAIRO_LIBS=-l${HOME}/usr/local/lib/libcairo.so
>>
>> I am not 100% sure of the syntax, but this may work.
>>
>> Note that my pkg-config gives me this for cairo:
>>
>> $ pkg-config --cflags --libs cairo
>> -I/usr/include/cairo -I/usr/include/glib-2.0
>> -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1
>> -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/libdrm
>>  -lcairo
>>
>> There are many more -I directives than what you had, but I'm not sure
>> if all of it is really necessary. if your configure or compilation
>> fail, it is something to keep in mind.
>>
>> HTH,
>>
>> Peter
>>
>> On Mon, Apr 28, 2014 at 8:16 PM, Fong Chun Chan <fongchunchan@gmail.com>
>> wrote:
>> > Thanks Peter. From the config.log file, the issue appears to occur here
>> at
>> > the "/home/fong/Cairo/conftest.c:28: undefined reference to
>> `cairo_create'"
>> >
>> >
>> > -----
>> >
>> > configure:3631: gcc -std=gnu99 -o conftest -g -O2
>> > -I/home/fong/usr/local/include/cairo   conftest.c -lz
>> > -L/home/fong/usr/local/lib >&5
>> > configure:3631: $? = 0
>> > configure:3648: result: -lz
>> > configure:3657: checking whether Cairo programs can be compiled
>> > configure:3671: gcc -std=gnu99 -o conftest -g -O2
>> > -I/home/fong/usr/local/include/cairo   conftest.c -lz
>> > -L/home/fong/usr/local/lib >&5
>> > /tmp/ccIr2WlB.o: In function `main':
>> > /home/fong/Cairo/conftest.c:28: undefined reference to `cairo_create'
>> > collect2: ld returned 1 exit status
>> > configure:3671: $? = 1
>> > configure: failed program was:
>> > | /* confdefs.h */
>> > | #define PACKAGE_NAME "Cairo"
>> > | #define PACKAGE_TARNAME "cairo"
>> > | #define PACKAGE_VERSION "1.3"
>> > | #define PACKAGE_STRING "Cairo 1.3"
>> > | #define PACKAGE_BUGREPORT "Simon.Urbanek@r-project.org"
>> > | #define PACKAGE_URL ""
>> > | #define STDC_HEADERS 1
>> > | #define HAVE_SYS_WAIT_H 1
>> > | #define HAVE_SYS_TYPES_H 1
>> > | #define HAVE_SYS_STAT_H 1
>> > | #define HAVE_STDLIB_H 1
>> > | #define HAVE_STRING_H 1
>> > | #define HAVE_MEMORY_H 1
>> > | #define HAVE_STRINGS_H 1
>> > | #define HAVE_INTTYPES_H 1
>> > | #define HAVE_STDINT_H 1
>> > | #define HAVE_UNISTD_H 1
>> > | #define HAVE_STRING_H 1
>> > | #define HAVE_SYS_TIME_H 1
>> > | #define HAVE_UNISTD_H 1
>> > | /* end confdefs.h.  */
>> >
>> >
>> > On Mon, Apr 28, 2014 at 7:50 PM, Peter Langfelder
>> > <peter.langfelder@gmail.com> wrote:
>> >>
>> >> On Mon, Apr 28, 2014 at 7:14 PM, Fong Chun Chan <
>> fongchunchan@gmail.com>
>> >> wrote:
>> >> > Hi Peter,
>> >> >
>> >> > Thanks for the reply. I don't have access to the package manager
>> >> > unfortunately as I am working on a cluster where I don't have admin.
>> So
>> >> > everything has to installed into my ~/export
>> >> > CAIRO_LIBS=-L${HOME}/usr/local/lib
>> >> > export CAIRO_CFLAGS=-I${HOME}/usr/local/include
>> >> > /local. I tried looking into homebrew/linuxbrew, but the gcc compiler
>> >> > (4.1.2) is not suitable for linuxbrew and installing a new gcc
>> compiler
>> >> > isn't a simply endeavor from source.
>> >>
>> >> I see - in that case I think you are on the right track.
>> >>
>> >> >
>> >> > I installed cairo from source specifically the
>> >> > http://cairographics.org/releases/cairo-1.12.16.tar.xz download.
>> What is
>> >> > this cairo-devel you are referring to? It seems to be something
>> related
>> >> > to
>> >> > using the package manager?
>> >>
>> >> If you install from source, you (usually) also get the development
>> >> files (the content of cairo-devel) by default.
>> >>
>> >> >
>> >> > In any case, your second point about the "-L for library directories,
>> >> > and -I
>> >> > for
>> >> > include directories" was actually useful. Rather than remove those
>> lines
>> >> > (as
>> >> > that didn't help), I modified my ~/.bashrc a bit (I am also limited
>> in
>> >> > my
>> >> > understanding paths)
>> >> >
>> >> > export CAIRO_LIBS=-L${HOME}/usr/local/lib
>> >> > export CAIRO_CFLAGS=-I${HOME}/usr/local/include
>> >> >
>> >> > This actually got around that issue! But now I've run into another
>> >> > issue:
>> >> >
>> >> > checking for pkg-config... /home/fong/usr/local/bin/pkg-config
>> >> > configure: CAIRO_CFLAGS=-I/home/fong/usr/local/include/cairo
>> >> > checking if R was compiled with the RConn patch... no
>> >> > checking cairo.h usability... yes
>> >> > checking cairo.h presence... yes
>> >> > checking for cairo.h... yes
>> >> > checking for PNG support in Cairo... yes
>> >> > checking for ATS font support in Cairo... no
>> >> > configure: CAIRO_LIBS=-L/home/fong/usr/local/lib
>> >> > checking for library containing deflate... -lz
>> >> > checking whether Cairo programs can be compiled... configure: error:
>> >> > Cannot
>> >> > compile a simple Cairo program. See config.log for details.
>> >> > ERROR: configuration failed for package 'Cairo'
>> >>
>> >> If you look at the config.log file and post the releavant part (don't
>> >> post the whole thing, it's huge), I (or R compiling experts) can try
>> >> to help you more.
>> >>
>> >> Peter
>> >
>> >
>>
>
>

	[[alternative HTML version deleted]]

