RQuantLib won't load when deploying a shiny app - r

I am having an issue when deploying a shiny app that requires the package RQuantLib. When I'm running my application, everything works fine, even the part where the RQuantLib package is needed. However, when deploying the application, the process is stopped when building the package RQuantLib.
When I put into comments the line "library(RQuantLib)" the application can be deployed but I am obviously missing my parts based on the use of this package.
Here's the error :
[2018-11-17T22:26:33.546919933+0000] Building R package: RQuantLib (0.4.5)
/mnt/packages/build /mnt
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *source* package ‘RQuantLib’ ...
** package ‘RQuantLib’ successfully unpacked and MD5 sums checked
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for R... yes
checking for quantlib-config... yes
configure: WARNING: RQuantLib requires QuantLib (>= 1.8.0).
configure: error: Please upgrade to a current version.
ERROR: configuration failed for package ‘RQuantLib’
* removing
‘/opt/R/3.5.0/lib/R/library/RQuantLib’################################# End
Task Log #################################
Erreur : Unhandled Exception: Child Task 565972976 failed: Error building
image: Error building RQuantLib (0.4.5). Build exited with non-zero status:
1
De plus : Warning message:
Error detecting locale: Error in read.table(file = file, header = header,
sep = sep, quote = quote, : incomplete final line found by readTableHeader
on 'raw'
(Using default: en_US)
Thank you in advance !

RQuantLib author here. I actually try to make this as plain as I can:
configure: WARNING: RQuantLib requires QuantLib (>= 1.8.0).
configure: error: Please upgrade to a current version.
ERROR: configuration failed for package ‘RQuantLib’
Also not sure what system you are on (as you didn't say) but both Debian and Ubuntu
have RQuantLib natively: sudo apt install r-cran-rquantlib is all it takes.
Otherwise it may be worth re-stating the somewhat obvious: to build RQuantLib from source you need both R and QuantLib on the system you are building (== installing) on if you install from source. Hence the attractiveness of installing binaries -- which I provide as Debian maintainer.

Related

Compile R packages from source (Mac OS X)

I'm running Mac OS X 10.7.5 (Lion), which means that the latest version of R I can run is 3.2.1. Since binaries of packages are no longer being made for this version, it means that I need to install the latest package versions from source. I can do this with
install.packages(pkgs, type = "source")
I installed GNU Fortran, although it's not clear to me whether I need it or not in order to compile R packages.
When I try to compile packages from source in R, however, I get error messages indicating that I don't have (or that R cannot find) the necessary compiling tools. Cf. e.g.:
* installing *source* package ‘scales’ ...
** package ‘scales’ successfully unpacked and MD5 sums checked
** libs
sh: make: command not found
ERROR: compilation failed for package ‘scales’
and
* installing *source* package ‘stringi’ ...
** package ‘stringi’ successfully unpacked and MD5 sums checked
checking for local ICUDT_DIR... icu55/data
checking for R_HOME... /Library/Frameworks/R.framework/Resources
checking for R... /Library/Frameworks/R.framework/Resources/bin/R
checking for R >= 3.1.0 for C++11 use... yes
checking for R < 3.4.0 for CXX1X flag use... yes
checking for cat... /bin/cat
/Library/Frameworks/R.framework/Resources/bin/config: line 150: make: command not found
[...]
checking for gcc... no
checking for cc... no
checking for cl.exe... no
/Library/Frameworks/R.framework/Resources/bin/config: line 153: make: command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 269: make: command not found
configure: error: in `/private/var/folders/2r/6c5vhb4s3zx3zs4d1dbf9p940000gn/T/Rtmpob4pMm/R.INSTALLd4676ad8595/stringi':
configure: error: no acceptable C compiler found in $PATH
I assume what's needed is to install the necessary compiling tools for R packages. What do I need to do?
(If I need to provide additional information, just ask for it in a comment, and I will provide it)
It might be tricky. First of all, double check whether you can download XCode from AppStore or not. If you can, you will be able to install command line tools as well. Either via Preferences -> Downloads (as far as I recall), or they will be installed during first startup.
Alternatively, create free account here:
http://developer.apple.com
Then, head to:
https://developer.apple.com/download/more/
and find XCode. It might be you will need to install some really old version.
As #hrbrmstr mentioned, it might be that installing virtual machine (e.g. inside VirtualBox) with Linux will be less painful.
Note that you will probably encounter more and more issues while installing packages. There is no easy way if you are forced to stick with old OS X :(
Update:
As #Sverre pointed out, it would be better to have a complete list of links here:
XCode - (Lion version) download from Apple (not to confuse with AppStore)
Command Line Tools - (Lion version) you can install them separately, without installing XCode

how to specify which R lib to use when installing a R package?

I was trying to use a R package called "XML",
but had trouble to use it after installation:
# in R environment
> library("XML")
> XML::parseURI("")
Error in XML::parseURI("") : cannot parse URI
the issue turned out to be that R could not find the current version of "libxml2" installed in my directory:
echo $LD_LIBRARY_PATH /somewhere/Jun/Programme/libxml2-devel-2.9.1-2.1/usr/lib/:
retrieve information about the version of the libxml2 library "XML" linking to
> path = unclass(getLoadedDLLs()[["XML"]])$path
> path
[1] "/misc/home/Jun/Programme/R-3.3.1/lib64/R/library/XML/libs/XML.so"
> system2("ldd",args=path)
linux-vdso.so.1 => (0x00007fff2a9e8000)
libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00002aefc088a000) # XML is using a common "libxml2.so.2" not the one I installed.
libz.so.1 => //home/Jun/Programme/zlib-1.2.11/lib/libz.so.1 (0x00002aefc0bc8000)
libm.so.6 => /lib64/libm.so.6 (0x00002aefc0de5000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002aefc1068000)
...
Any suggestion to do that?
in order to make "XML" link to the libxml2 installed in my directory,
I made such efforts:
setting PATH for libxml2:
echo $LD_LIBRARY_PATH
/somewhere/Jun/Programme/pcre-8.40/lib/:/somewhere/Jun/Programme/xz-5.2.3/lib/:/somewhere/Jun/Programme/zlib-1.2.11/include/:/somewhere/Jun/Programme/zlib-1.2.11/lib/:/somewhere/Jun/Programme/bzip2-1.0.6/lib/:/somewhere/Jun/Programme/bzip2-1.0.6/include/:/somewhere/Jun/Programme/gcc-6.1.0/lib/:/somewhere/Jun/Programme/gcc-6.1.0/lib64/:/somewhere/Jun/Programme/libxml2-devel-2.9.1-2.1/usr/lib/:/somewhere/Jun/Programme/curl-7.52.1/lib/:/somewhere/Jun/Programme/libtool_CentOS6_64/usr/lib64/:/home/appl/openmpi-1.3.1/lib:/opt22/lsf83_exp/8.3/linux2.6-glibc2.3-x86_64/lib:/opt/ups/lib
recompile R with configuration specifying lib using "--enable" argument
./configure --prefix=$HOME/Programme/R-3.3.1 --enable-R-shlib LDFLAGS="-L/$HOME/Programme/zlib-1.2.11/lib -L/$HOME/Programme/bzip2-1.0.6/lib -L/$HOME/Programme/xz-5.2.3/lib -L/$HOME/Programme/pcre-8.40/lib -L/$HOME/Programme/curl-7.52.1/lib " CPPFLAGS="-I/$HOME/Programme/zlib-1.2.11/include -I/$HOME/Programme/bzip2-1.0.6/include -I/$HOME/Programme/xz-5.2.3/include -I/$HOME/Programme/pcre-8.40/include -I/$HOME/Programme/curl-7.52.1/include"
install "XML" with configure arguments:
biocLite("XML",configure.args='--with-xml- config="/somewhere/Jun/Programme/libxml2-devel-2.9.1-2.1/usr/bin/xml2-config"')
BioC_mirror: http://bioconductor.org
Using Bioconductor 3.4 (BiocInstaller 1.24.0), R 3.3.1 (2016-06-21).
Installing package(s) ‘XML’
trying URL 'http://cran.rstudio.com/src/contrib/XML_3.98-1.5.tar.gz'
Content type 'application/x-gzip' length 1599213 bytes (1.5 MB)
downloaded 1.5 MB
...
but none of them seemed to work:
* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for sed... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
User defined xml-config: /somewhere/Jun/Programme/libxml2-devel-2.9.1-2.1/usr/bin/xml2-config, XML Version: 2, XML2: yes
USE_XML2 = yes
SED_EXTENDED_ARG: -r
Minor 9, Patch 1 for 2.9.1
Located parser file -I/usr/include/libxml2/parser.h
checking for gzopen in -lz... yes
checking for xmlParseFile in -lxml2... yes
checking for xmlHashSize in -lxml2... yes
Using built-in xmlHashSize
Checking DTD parsing (presence of externalSubset)...
checking for xmlHashSize in -lxml2... yes
Found xmlHashSize
checking for xmlOutputBufferCreateBuffer in -lxml2... yes
have xmlOutputBufferCreateBuffer()
checking for xmlDocDumpFormatMemoryEnc in -lxml2... yes
checking libxml/xmlversion.h usability... yes
checking libxml/xmlversion.h presence... yes
checking for libxml/xmlversion.h... yes
Expat: FALSE
Checking for return type of xmlHashScan element routine.
No return value for xmlHashScan
xmlNs has a context field
Checking for cetype_t enumeration
Using recent version of R with cetype_t enumeration type for encoding
checking for xmlsec1-config... /usr/bin/xmlsec1-config
nodegc default
xml-debug default
No XML_WITH_ZLIB enumeration value.
Version has xmlHasFeature()
****************************************
Configuration information:
Libxml settings
libxml include directory: -I/usr/include/libxml2
libxml library directory: -lxml2 -lz -lm -ldl -lz -lxml2
libxml 2: -DLIBXML2=1
I think I have found the solution. Instead of using rpm to install "libxml2"
(I apologize that I did not mention it in my post; I didn't realize that it could be the cause of my trouble), I ought to have compiled "libxml2" from source.
For people that have a similar issue:
Download the current version of libxml2 http://www.linuxfromscratch.org/blfs/view/svn/general/libxml2.html,
following the instructions of the link above.
Two points for installation:
1.
./configure --prefix=$HOME/Programme --disable-static --with-history --with-zlib=/somewhere/Jun/Programme/zlib-1.2.11 && make
you have to specify zlib (--with); this also means that you have to have zlib installed. I had to add "--with" to make configure work.
The instructions state that you have to call "make install" as root user, but no, you don't have to do this.
Set the PATH for your installed "libxml2".
Reinstall your R package "XML".

linux redhat gsl R installation error: cannot run C compiled programs.

I was trying to install the R gsl wrapper in our university's HPC cluster, with R version 3.1.1 and OS x86_64-redhat-linux-gnu (64-bit). But something weird happened:
R CMD INSTALL '/d1/pyangac/gsl_1.9-10.1.tar.gz'
* installing to library /d1/pyangac/R_libs/ installing *source* package gsl...
** package gsl successfully unpacked and MD5 sums checked
checking for gsl-config... /usr/local/gsl-1.16/bin/gsl-config
checking if GSL version >= 1.12... checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
ERROR: configuration failed for package gsl
* removing /d1/pyangac/R_libs/gsl
Here are some specifics I have made before I run the installation command. There are two gsl libraries already installed in the cluster, one is gsl, and the other is gsl-1.16 (version 1.16). As the R gsl wrapper requires external gsl library version >= 1.12, before installation, I have set the environments LDFLAGS="-L/usr/local/gsl-1.16/lib -lgsl -lgslcblas -lm"; export LDFLAGS and CPPFALGS="-I/usr/local/gsl-1.16/include"; export CPPFLAGS, so that R will install the wrapper based on version 1.16. I also added the following two paths to make sure R will find the gsl-config file export PATH=$PATH:/usr/local/gsl-1.16, and export PATH=$PATH:/usr/local/gsl-1.16/bin.
Then I run the previous installation command and the error suggests that the C compiler cannot work. After some searches I think it may be caused by the fact that the gsl library is not in the gcc include directory. After typing the following commands, I think the problem would be solved:
export CPATH=/usr/local/gsl-1.16/include
Unfortunately, when I reinstall the gsl wrapper, the same 'cannot run C compiled programs' error appears again. Sorry that I can't provide any further information, as I cannot find the config.log file.
Does anyone has any hint why this is happening, or how to find the config.log file?
Thanks.
checking whether the C compiler works... configure: error: cannot run
C compiled programs
# yum install gcc-c++
I.e. the install of gcc-c++ will also install the dependencies that make gcc work. ( The gcc missing parts are { glibc-devel, glibc-headers, linux-headers } → /usr/lib64/[files], /usr/include/[files].h )

How to install rgdal and rgeos package in R on university high performance computing system?

I have been installing R packages from tar.gz type files on Edinburgh university's compute and data facility which is a high performance computing cluster which is accessed via SSH. Once logged in, I can install the files as the example below:
install.packages("/exports/work/eng_AntonyHydroData/Pkges/DEoptim_2.2-3.tar.gz",rpeo=NULL,target="source")
There are approximately 40 packages and 38 of them install no problem, but two fail: RGEOS (rgeos_0.3-14.tar.gz) and RGDAL (rgdal_1.0-7.tar.gz).
The reason for failure is given below:
Installing package into '/exports/work/eng_AntonyHydroData/library'
(as 'lib' is unspecified)
inferring 'repos = NULL' from 'pkgs'
* installing *source* package 'rgdal' ...
** package 'rgdal' successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgdal: 1.0-5
checking for /usr/bin/svnversion... yes
configure: svn revision: 559
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package 'rgdal'
Note that RGEOS gives the same reason i.e. gdal-config is missing.
I have looked around the net and have found various answers to this problem that mainly suggests to install libgeos-dev or something similar using the command 'sudo' or 'apt-get' but neither of these commands are recognised by the computing cluster system.
Any help in getting RGEOS and RGDAL to work would be very much appreciated.
Antony
I managed to solve this by first installing the geos-3.5.0.tar.bz2 package and issuing the following linux commands:
tar xjvf geos-3.5.0.tar.bz2
cd geos-3.5.0
./configure --help
mkdir /exports/work/....
./configure --help,
./configure --prefix=eng_A... --enable-python
make
make check
make install
and similar for rgdal
I'm not sure how your HPC system is setup but as the previous comment implied, you need "geos" installed/loaded. The system I work on uses the "module" command to load programs, so I use "module available" to find where "geos" is on the system so you can load it.
Here's an example from another system: http://docs.hpc.shef.ac.uk/en/latest/iceberg/software/apps/r.html

Setting up configure/makevars for libcouchbase in R?

I am creating a new R package where I would like to call an external c library(libcouchbase).
My problem is how to get the package build system to find the libraries during linking. I am using a linux/ubuntu like system.
This is what I had so far do :
create an configure.ac
AC_INIT(rcouchbase, version-0.1)
AC_CHECK_LIB([couchbase], [lcb_create], [],
[AC_MSG_ERROR(Failed to locate libcouchbase >= 2.0.0)])
COUCHBASE_LIBS="$LIBS"
AC_SUBST(COUCHBASE_LIBS)
AC_OUTPUT(src/Makevars)
generate a configure using autoconf
system("autoconf configure.ac > configure | chmod +x configure")
create a makevars.in
# set by configure
COUCHBASE_LIBS = #COUCHBASE_LIBS#
PKG_LIBS = $(COUCHBASE_LIBS)
build my package:
When I build my package, the configure file sucess to find the
==> R CMD INSTALL --no-multiarch --with-keep.source rcouchbase
Here the some significant output:
==> R CMD INSTALL --no-multiarch --with-keep.source rcouchbase
* installing to library ‘/home/agstudy/R/packages’
* installing *source* package ‘rcouchbase’ ...
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for lcb_create in -lcouchbase... yes
configure: creating ./config.status
config.status: creating src/Makevars
make: Nothing to be done for `all'.
** libs
installing to /home/agstudy/R/packages/rcouchbase/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/agstudy/R/packages/rcouchbase/libs/rcouchbase.so':
/home/agstudy/R/packages/rcouchbase/libs/rcouchbase.so: undefined symbol: lcb_destroy
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/agstudy/R/packages/rcouchbase’
Exited with status 1.
So does anyone know what I should add to my makevars/config file to solve the linkng problem?
EDIT add shared library dependencies:
ldd libcouchbase.so
linux-vdso.so.1 => (0x00007fff0a7fe000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fea0a26e000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fea0a06a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fea09ca1000)
/lib64/ld-linux-x86-64.so.2 (0x00007fea0a7c5000)
When you say COUCHBASE_LIBS="$LIBS", who is filling in $LIBS for you?
At a first step, try to decompose the issue. You should us pieces: src/Makevars.in, but
not the generated src/Makevars. Does it have the correct library listed?
Also, look at / show us R CMD INSTALL ... output. Is there a link step with the library?
What you posted suggests not as the lcb_destroy symbol is missing.
In case you want to learn about Autotools / Automake, I have gone back to this (older) tutorial a few times; you may find it useful.
Edit: You are still confused. We don't want to see ldd libcouchbase; we presume that one is fine. Your package does not load so we need its linking step and its ldd output.
I.e. my RQuantLib package ends its R CMD INSTALL on
g++ -shared -o RQuantLib.so [many .o files removed] \
-L/usr/lib -lQuantLib -L/usr/lib/R/lib -lR
which clearly shows that it does link with the (required) QuantLib library.

Resources