I have released an R package on CRAN which depends on the successful compilation of some RcppArmadillo code. The package built correctly and with no notes on all the test systems that I tried (CRAN comments here if interested), however, the CRAN checks fail on solaris-sparc and are unable to load a dependency on solaris-x86.
See here for CRAN checks.
The reason for the error is given as ld: fatal: library -llapack: not found (from goldi-00install.html).
In my Makevars and Makevars.win, I have stated -llapack in PKG_LIBS, which I thought was sufficient.
PKG_LIBS= -Wsign-compare -llapack in both.
However, I'm unsure how to declare this dependency for Solaris. Is there a separate Makevars that I must write, or there a different location that I must state the dependency?
I have read the relevant section of the "Writing R Extensions" manual, and suspect that I may have to declare $(LLAPACK_LIBS) in PKG_LIBS, but have no way of testing it on a solaris platform. Is this the correct path to follow?
Thanks for any help, it's much appreciated.
Package on Github
Package on CRAN
Your line in src/Makevars is just wrong. Don't do what you did:
PKG_LIBS= -Wsign-compare -llapack
do what we all do, what the example package has and the what the auto-generated package gets:
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
Believe us when we say that it just works. I venture that among the two-hundred-ninenty-one (291 !!) packages on CRAN, essentially all use this.
And any who do not, like yours, simply do it wrong. The above dispatches to what R knows about LAPACK and its dependencies. Use it.
Related
I have some C++ code that I intend to export into my r package using Rcpp. However, this code links to fftw3 via
#include <fftw3.h>
at the top of the file. When I try to compile this code, I unsurprisingly get the error
fatal error: 'fftw3.h' file not found
What is the proper way to link to this file so that it will be available upon compilation of my package? I know that a Makevars file can generally be used to link to system libraries but since this library is external I'm not sure what to do.
Thanks,
Eric.
Please see the Rcpp vignette Rcpp libraries -- which is also this arXiv paper.
There are many examples among the 2400+ CRAN packages using Rcpp. My hunch would probably be to look at what I contributed to the nloptr package -- even though that is a more complicated scheme where we allow use either a system library if present (could be the case with fftw3 too) or downloand and build.
Rcpp has been used a lot to build such glue. The most common, and simplest , approach is to look for pkg-config and query it for headers and libraries. Please give that a shot (with some looking around CRAN or GitHub for examples).
Edit: There is also an (old) fftw3 package by Gabor at his previous employer's GitHub org as well as another CRAN package fftwtools (which, if memory served, I helped once too but I don't recall now what for).
I have some C++ code that I intend to export into my r package using Rcpp. However, this code links to fftw3 via
#include <fftw3.h>
at the top of the file. When I try to compile this code, I unsurprisingly get the error
fatal error: 'fftw3.h' file not found
What is the proper way to link to this file so that it will be available upon compilation of my package? I know that a Makevars file can generally be used to link to system libraries but since this library is external I'm not sure what to do.
Thanks,
Eric.
Please see the Rcpp vignette Rcpp libraries -- which is also this arXiv paper.
There are many examples among the 2400+ CRAN packages using Rcpp. My hunch would probably be to look at what I contributed to the nloptr package -- even though that is a more complicated scheme where we allow use either a system library if present (could be the case with fftw3 too) or downloand and build.
Rcpp has been used a lot to build such glue. The most common, and simplest , approach is to look for pkg-config and query it for headers and libraries. Please give that a shot (with some looking around CRAN or GitHub for examples).
Edit: There is also an (old) fftw3 package by Gabor at his previous employer's GitHub org as well as another CRAN package fftwtools (which, if memory served, I helped once too but I don't recall now what for).
When I try to compile R packages from source, it uses the compilers and settings defined in etc/Makeconf within the R installation directory. How can I override these settings?
I have an ~/.R/Makevars file (suggested e.g. here), and I included the settings I want there, but these are not being used for some reason. Why not, and how can I fix this?
I could not find the official documentation on ~/.R/Makevars and Makeconf—links would be welcome.
In the past, this very same setup used to work correctly for me, but recently it doesn't. I assume something must have changed in recent R versions, but I am not sure when. Were there any recent changes that could have affected this?
Motivation and context:
I am on macOS and I want to use gfortran from MacPorts. Thus I set FC = /opt/local/bin/gfortran-mp-11 and FLIBS = -L/opt/local/lib/gcc11 -lgfortran -lquadmath -lm in ~/.R/Makevars. However, the system still wants to use a gfortran installation in /usr/local, which does not exist on my machine. It clearly takes the paths and options from etc/Makeconf. I am using the official R binaries.
It turns out that the reason why ~/.R/Makevars was ignored on my machine when trying to build a certain package was a bug in withr:
https://github.com/r-lib/withr/issues/169
Installing the development version of withr using devtools::install_github("r-lib/withr#master") fixed the problem.
Here is the GitHub repo of my R package
I've been able to install this package from source on Windows, MacOS, and a Linux cluster with devtools::install_github("ntthung/ldsr")
I'm trying to integrate Travis CI and upon build, I get the following error
Error: package or namespace load failed for ‘ldsr’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/tmp/RtmpK7z3X6/Rinst2ef05609c709/00LOCK-ldsr/00new/ldsr/libs/ldsr.so':/tmp/RtmpK7z3X6/Rinst2ef05609c709/00LOCK-ldsr/00new/ldsr/libs/ldsr.so: undefined symbol: dpotrf_
I found that dpotrf_ belongs to a library called libflame. So I made the file Rload.R with te command Sys.setenv("PKG-LIBS"="-llibflame") and added the following to .travis.yml
script:
- Rscript Rload.R
- R CMD build . --compact-vignettes=gs+qpdf
- R CMD check *tar.gz --as-cran
But I still get the same error.
My package uses Rcpp and RcppArmadillo.
Help please! Thanks.
This looks like the basic error of not having a proper src/Makevars as would have been created from e.g. RcppArmadillo.package.skeleton() and others.
So as a first basic fix attempt, copy in the file inst/skeleton/Makevars from RcppArmadillo which contains
## With R 3.1.0 or later, you can uncomment the following line to tell R to
## enable compilation with C++11 (where available)
##
## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider
## availability of the package we do not yet enforce this here. It is however
## recommended for client packages to set it.
##
## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP
## support within Armadillo prefers / requires it
CXX_STD = CXX11
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
You did copy in the Windows variant Makevars.win you just forgot the main one.
And dpotrf_ is a standard LAPACK symbol so the error is an obvious one for more experienced users (and this question is likely a duplicate too). Also, looking at the sources of the 600+ other CRAN packages using RcppArmadillo is often a good idea too -- they are all on GitHub under user cran.
I am the mantainer of few R packages that use Rcpp for some core calculations. Wishing to try a new feature of the Rcpp package as described in Rcpp 0.12.18 Rbloggers
To do so I did the following:
I created a Makevars and Makevars.win in my scr folder, both contaning the line CPPFLAGS += -DRCPP_USE_UNWIND_PROTECT
I added the SystemRequirements: GNU make entry in the DESCRIPTION file.
Btw that raises some issues that I wounder will make my package rejected on CRAN:
following Warning message in compiling my package:
checking compilation flags in Makevars ... WARNING Variables overriding user/site settings: CPPFLAGS: -o /dev/null -DRCPP_USE_UNWIND_PROTECT
Note: GNU make is a system requirement
I would like to know if it is possible to rewrite the Makevars to remove the warning and possibly, the Gnu make requirement
Thanks in advance for the attention
You want to use PKG_CPPFLAGS (or PKG_CXXFLAGS) as that is the per-package variant. What you altered is the system-wide version hence the warning.
More details are as always in the Writing R Extensions manual, otherwise the many existing example packages (all on CRAN and browseable at GitHub) can help too.
For example, here is the one-toggle-setting use case from the RcppExamples package:
PKG_CXXFLAGS = -DRCPP_NEW_DATE_DATETIME_VECTORS
(which is strictly-speaking no longer needed as the "new" Date and Datetime vector classes became the default a while ago).
Also, if you use this form you do not need the += and have no requirement to declare on GNU make -- another win.