ropensci / rsvg

SVG renderer for R based on librsvg2
Other
95 stars 1 forks source link

Cannot install rsvg with librsvg-2.0 is installed in non-standard location / bug in ./configure #5

Closed fthommen closed 4 years ago

fthommen commented 7 years ago

Hi,

I am unable to install rsvg when librsvg-2.0 is installed in a non-standard location despite defining $PKG_CONFIG_PATH, because systemwide installed headerfiles are then not found:

$ export PKG_CONFIG_PATH=/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64/pkgconfig
$ R

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

[...]

> install.packages("rsvg")
[...]

* installing *source* package ‘rsvg’ ...
** package ‘rsvg’ successfully unpacked and MD5 sums checked
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 
Using PKG_LIBS=-L/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64 -lrsvg-2 -lgdk_pixbuf-2.0 -lart_lgpl_2 -lxml2 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype 
** libs
gcc -std=gnu99 -I/ibios/tbi_cluster/13.1/x86_64/R/R-3.3.1/lib64/R/include -DNDEBUG -pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2  -I/usr/local/include    -fpic  -g -O2  -c init.c -o init.o
init.c: In function ‘R_init_rsvg’:
init.c:7:3: warning: ‘g_type_init’ is deprecated (declared at /usr/include/glib-2.0/gobject/gtype.h:669) [-Wdeprecated-declarations]
   g_type_init();
   ^
gcc -std=gnu99 -I/ibios/tbi_cluster/13.1/x86_64/R/R-3.3.1/lib64/R/include -DNDEBUG -pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2  -I/usr/local/include    -fpic  -g -O2  -c rsvg.c -o rsvg.o
rsvg.c:3:19: fatal error: cairo.h: No such file or directory
 #include <cairo.h>
                   ^
compilation terminated.
make: *** [rsvg.o] Error 1
ERROR: compilation failed for package ‘rsvg’
* removing ‘/home/thommen/R/x86_64-pc-linux-gnu-library/3.3/rsvg’

The downloaded source packages are in
    ‘/tmp/RtmpRPvUVG/downloaded_packages’
Warning message:
In install.packages("rsvg") :
  installation of package ‘rsvg’ had non-zero exit status
> q()
Save workspace image? [y/n/c]: n
$

cairo.h is present in /usr/include/cairo/. Environment variables like $CFLAGS or $PKG_CFLAGS don't seem to be used by R.

I also tried to install the package from a locally downloade version with R CMD INSTALL:

$ export PKG_CONFIG_PATH=/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64/pkgconfig
$ R CMD INSTALL ./rsvg
* installing to library ‘/home/thommen/R/x86_64-pc-linux-gnu-library/3.3’
* installing *source* package ‘rsvg’ ...
** package ‘rsvg’ successfully unpacked and MD5 sums checked
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 
Using PKG_LIBS=-L/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64 -lrsvg-2 -lgdk_pixbuf-2.0 -lart_lgpl_2 -lxml2 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype 
** libs
gcc -std=gnu99 -I/ibios/tbi_cluster/13.1/x86_64/R/R-3.3.1/lib64/R/include -DNDEBUG -pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2  -I/usr/local/include    -fpic  -g -O2  -c init.c -o init.o
init.c: In function ‘R_init_rsvg’:
init.c:7:3: warning: ‘g_type_init’ is deprecated (declared at /usr/include/glib-2.0/gobject/gtype.h:669) [-Wdeprecated-declarations]
   g_type_init();
   ^
gcc -std=gnu99 -I/ibios/tbi_cluster/13.1/x86_64/R/R-3.3.1/lib64/R/include -DNDEBUG -pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2  -I/usr/local/include    -fpic  -g -O2  -c rsvg.c -o rsvg.o
rsvg.c:3:19: fatal error: cairo.h: No such file or directory
 #include <cairo.h>
                   ^
compilation terminated.
make: *** [rsvg.o] Error 1
ERROR: compilation failed for package ‘rsvg’
* removing ‘/home/thommen/R/x86_64-pc-linux-gnu-library/3.3/rsvg’
$

When defining INCLUDE_DIR and LIB_DIR on the commandline, then $PKG_CONFIG_PATH is ignored:

$ export PKG_CONFIG_PATH=/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64/pkgconfig
$ R CMD INSTALL --configure-vars='INCLUDE_DIR="/usr/include/cairo" LIB_DIR="/usr/lib"' ./rsvg
* installing to library ‘/home/thommen/R/x86_64-pc-linux-gnu-library/3.3’
* installing *source* package ‘rsvg’ ...
** package ‘rsvg’ successfully unpacked and MD5 sums checked
Found INCLUDE_DIR and/or LIB_DIR!
Using PKG_CFLAGS=-I/usr/include/cairo 
Using PKG_LIBS=-L/usr/lib -lrsvg
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because librsvg-2.0 was not found. Try installing:
 * deb: librsvg2-dev (Debian, Ubuntu, etc)
 * rpm: librsvg2-devel (Fedora, EPEL)
 * csw: librsvg_dev, sunx11_devel (Solaris)
 * brew: librsvg (OSX)
If librsvg-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a librsvg-2.0.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘rsvg’
* removing ‘/home/thommen/R/x86_64-pc-linux-gnu-library/3.3/rsvg’
$

And when setting INCLUDE_DIR and LIB_DIR for all pathes including librsvg-2.0, the situation doesn't change, even though it should:

$ export PKG_CONFIG_PATH=/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64/pkgconfig
$ R CMD INSTALL --configure-vars='INCLUDE_DIR="/usr/include/cairo -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2/librsvg" LIB_DIR="/usr/lib -L/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64"' ./rsvg
* installing to library ‘/home/thommen/R/x86_64-pc-linux-gnu-library/3.3’
* installing *source* package ‘rsvg’ ...
** package ‘rsvg’ successfully unpacked and MD5 sums checked
Found INCLUDE_DIR and/or LIB_DIR!
Using PKG_CFLAGS=-I/usr/include/cairo -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2/librsvg 
Using PKG_LIBS=-L/usr/lib -L/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64 -lrsvg
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because librsvg-2.0 was not found. Try installing:
 * deb: librsvg2-dev (Debian, Ubuntu, etc)
 * rpm: librsvg2-devel (Fedora, EPEL)
 * csw: librsvg_dev, sunx11_devel (Solaris)
 * brew: librsvg (OSX)
If librsvg-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a librsvg-2.0.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘rsvg’
* removing ‘/home/thommen/R/x86_64-pc-linux-gnu-library/3.3/rsvg’
$

When trying the installation completely manually, the ./configure step still fails:

$ export PKG_CONFIG_PATH=/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64/pkgconfig
$ export R_HOME=/ibios/tbi_cluster/13.1/x86_64/R/R-3.3.1
$ ./configure
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 
Using PKG_LIBS=-L/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64 -lrsvg-2 -lgdk_pixbuf-2.0 -lart_lgpl_2 -lxml2 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype 
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because librsvg-2.0 was not found. Try installing:
 * deb: librsvg2-dev (Debian, Ubuntu, etc)
 * rpm: librsvg2-devel (Fedora, EPEL)
 * csw: librsvg_dev, sunx11_devel (Solaris)
 * brew: librsvg (OSX)
If librsvg-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a librsvg-2.0.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
$

And running ./configure in verbose mode ( sh -x ./configure) shows why::

$ export PKG_CONFIG_PATH=/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64/pkgconfig
$ export R_HOME=/ibios/tbi_cluster/13.1/x86_64/R/R-3.3.1
$ sh -x ./configure
+ PKG_CONFIG_NAME=librsvg-2.0
+ PKG_DEB_NAME=librsvg2-dev
+ PKG_RPM_NAME=librsvg2-devel
+ PKG_CSW_NAME='librsvg_dev, sunx11_devel'
+ PKG_BREW_NAME=librsvg
+ PKG_TEST_HEADER='<librsvg/rsvg.h>'
+ PKG_LIBS=-lrsvg
+ PKG_CFLAGS=
+ pkg-config --version
+ '[' 0 -eq 0 ']'
++ pkg-config --cflags librsvg-2.0
+ PKGCONFIG_CFLAGS='-pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 '
++ pkg-config --libs --silence-errors librsvg-2.0
+ PKGCONFIG_LIBS='-L/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64 -lrsvg-2 -lgdk_pixbuf-2.0 -lart_lgpl_2 -lxml2 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype '
+ '[' '' ']'
+ '[' '' ']'
+ '[' '-pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 ' ']'
+ echo 'Found pkg-config cflags and libs!'
Found pkg-config cflags and libs!
+ PKG_CFLAGS='-pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 '
+ PKG_LIBS='-L/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64 -lrsvg-2 -lgdk_pixbuf-2.0 -lart_lgpl_2 -lxml2 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype '
+ echo 'Using PKG_CFLAGS=-pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 '
Using PKG_CFLAGS=-pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 
+ echo 'Using PKG_LIBS=-L/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64 -lrsvg-2 -lgdk_pixbuf-2.0 -lart_lgpl_2 -lxml2 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype '
Using PKG_LIBS=-L/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/lib64 -lrsvg-2 -lgdk_pixbuf-2.0 -lart_lgpl_2 -lxml2 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype 
++ /ibios/tbi_cluster/13.1/x86_64/R/R-3.3.1/bin/R CMD config CC
+ CC='WARNING: ignoring environment value of R_HOME
gcc -std=gnu99'
++ /ibios/tbi_cluster/13.1/x86_64/R/R-3.3.1/bin/R CMD config CFLAGS
+ CFLAGS='WARNING: ignoring environment value of R_HOME
-g -O2'
++ /ibios/tbi_cluster/13.1/x86_64/R/R-3.3.1/bin/R CMD config CPPFLAGS
+ CPPFLAGS='WARNING: ignoring environment value of R_HOME
-I/usr/local/include'
+ echo '#include <librsvg/rsvg.h>'
+ WARNING: ignoring environment value of R_HOME gcc -std=gnu99 WARNING: ignoring environment value of R_HOME -I/usr/local/include -pthread -I/tbi/cluster/13.1/x86_64/librsvg/librsvg-2.0/include/librsvg-2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libart-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 WARNING: ignoring environment value of R_HOME -g -O2 -E -xc -
+ R_CONFIG_ERROR=1
+ '[' 1 ']'
+ echo '------------------------- ANTICONF ERROR ---------------------------'
------------------------- ANTICONF ERROR ---------------------------
+ echo 'Configuration failed because librsvg-2.0 was not found. Try installing:'
Configuration failed because librsvg-2.0 was not found. Try installing:
+ echo ' * deb: librsvg2-dev (Debian, Ubuntu, etc)'
 * deb: librsvg2-dev (Debian, Ubuntu, etc)
+ echo ' * rpm: librsvg2-devel (Fedora, EPEL)'
 * rpm: librsvg2-devel (Fedora, EPEL)
+ echo ' * csw: librsvg_dev, sunx11_devel (Solaris)'
 * csw: librsvg_dev, sunx11_devel (Solaris)
+ echo ' * brew: librsvg (OSX)'
 * brew: librsvg (OSX)
+ echo 'If librsvg-2.0 is already installed, check that '\''pkg-config'\'' is in your'
If librsvg-2.0 is already installed, check that 'pkg-config' is in your
+ echo 'PATH and PKG_CONFIG_PATH contains a librsvg-2.0.pc file. If pkg-config'
PATH and PKG_CONFIG_PATH contains a librsvg-2.0.pc file. If pkg-config
+ echo 'is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:'
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
+ echo 'R CMD INSTALL --configure-vars='\''INCLUDE_DIR=... LIB_DIR=...'\'''
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
+ echo --------------------------------------------------------------------
--------------------------------------------------------------------
+ exit 1
$

The problem seems to appear in lines 51, 52 and 53:

CC=$(${R_HOME}/bin/R CMD config CC)
CFLAGS=$(${R_HOME}/bin/R CMD config CFLAGS)
CPPFLAGS=$(${R_HOME}/bin/R CMD config CPPFLAGS)

All these commands return a warning WARNING: ignoring environment value of R_HOME as first line, which is then assigned to the variables $CC, $CFLAGS, $CPPFLAGS. Of course that cannot work.

I'm not sure if the error in ./configure is the one which triggers the failures when trying the installation from R or through R CMD INSTALL, though.

R is an installation installed from source. The system is openSuSE 13.1, x86_64.

The questions are:

  1. How are we supposed to run the installation when librsvg-2.0 is installed in a non-standard location, and
  2. how can we fix the bug in ./configure?

Cheers frank

requeijaum commented 6 years ago

Got this error when configuring FFMPEG today with Homebrew on macOS 10.11.6. I will try some stuff and keep this updated.


EDIT@ July 2nd:

https://gist.github.com/requeijaum/86f2d529bdc1ce56b3c00a82d1e1f474

Omitting "--with-librsvg" from the flags and using "--HEAD ffmpeg" got the build working.

kelrenmor commented 5 years ago

@fthommen did you ever resolve this issue? I'm having the same problem!

jeroen commented 4 years ago

The problem is that librsvg has many dependencies which you all need at include time. This is a bit unusual. So you must make sure that all these pc files are on the PKG_CONFIG_PATH.

For example in my machine:

# pkg-config --cflags librsvg-2.0
-I/usr/local/Cellar/libffi/3.3/include -I/usr/local/Cellar/librsvg/2.48.4/include/librsvg-2.0 -I/usr/local/Cellar/gdk-pixbuf/2.40.0/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/glib/2.64.2_1/include -I/usr/local/Cellar/cairo/1.16.0_3/include/cairo -I/usr/local/Cellar/glib/2.64.2_1/include -I/usr/local/Cellar/glib/2.64.2_1/include/glib-2.0 -I/usr/local/Cellar/glib/2.64.2_1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.44/include -I/usr/local/Cellar/pixman/0.40.0/include/pixman-1 -I/usr/local/Cellar/fontconfig/2.13.1/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/libpng/1.6.37/include/libpng16

It's also apparent from the hardcoded windows cflags which libraries are needed:

https://github.com/jeroen/rsvg/blob/a89457342b8475cbe394a7879ee500b42843a440/src/Makevars.win#L12-L17

I have slightly improved the configure script in rsvg 2.0, hopefully that helps.