[R] R Cairo Installation - Cannot find cairo.h!

Peter Langfelder peter.langfelder at gmail.com
Tue Apr 29 06:34:44 CEST 2014


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 at 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 at 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 at gmail.com> wrote:
>>
>> On Mon, Apr 28, 2014 at 7:14 PM, Fong Chun Chan <fongchunchan at 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
>
>



More information about the R-help mailing list