devtools::build issue with conda - r

this is my first Stack Overflow question so please do not mind the terminology.
I try to build a package using devtools::build using a conda environment from my WSL:
devtools::build('pkg')
However, i get the following error
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
When i diagnose the problem i get the following
> pkgbuild::check_build_tools(debug = TRUE)
Trying to compile a simple C file
Running /home/name/miniconda3/envs/pipeline_env/lib/R/bin/R CMD SHLIB foo.c
x86_64-conda-linux-gnu-cc -I"/home/name/miniconda3/envs/pipeline_env/lib/R/include" -DNDEBUG -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/name/miniconda3/envs/pipeline_env/include -I/home/name/miniconda3/envs/pipeline_env/include -Wl,-rpath-link,/home/name/miniconda3/envs/pipeline_env/lib -fpic -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/name/miniconda3/envs/pipeline_env/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/r-base-split_1648745733215/work=/usr/local/src/conda/r-base-4.1.3 -fdebug-prefix-map=/home/name/miniconda3/envs/pipeline_env=/usr/local/src/conda-prefix -c foo.c -o foo.o
/bin/sh: 1: x86_64-conda-linux-gnu-cc: not found
make: *** [/home/name/miniconda3/envs/pipeline_env/lib/R/etc/Makeconf:170: foo.o] Error 127

Related

sf install on Ubuntu fails - no member named SetAxisMappingStrategy

sf install on Ubuntu 18.04 fails with:
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/include -I'/usr/local/lib/R/site-library/Rcpp/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-J7pprH/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c signed_area.cpp -o signed_area.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/include -I'/usr/local/lib/R/site-library/Rcpp/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-J7pprH/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c stars.cpp -o stars.o
stars.cpp: In function ‘void CPL_create(Rcpp::CharacterVector, Rcpp::IntegerVector, Rcpp::NumericVector, Rcpp::CharacterVector, Rcpp::NumericVector, Rcpp::NumericVector)’:
stars.cpp:771:7: error: ‘class OGRSpatialReference’ has no member named ‘SetAxisMappingStrategy’
oSRS.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
^~~~~~~~~~~~~~~~~~~~~~
stars.cpp:771:30: error: ‘OAMS_TRADITIONAL_GIS_ORDER’ was not declared in this scope
oSRS.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/R/etc/Makeconf:177: recipe for target 'stars.o' failed
make: *** [stars.o] Error 1
ERROR: compilation failed for package ‘sf’
* removing ‘/usr/local/lib/R/site-library/sf’
The downloaded source packages are in
‘/tmp/RtmpDZ9Qvj/downloaded_packages’
Warning message:
In install.packages("sf") :
installation of package ‘sf’ had non-zero exit status
Any suggestions appreciated.
Solved by installing the development versions (sf_1.0-7) from GitHub with:
library(devtools)
install_github("r-spatial/sf")

`ld` error when installing hdp package in R

I am try to install the hdp package by Nicola Robers using the following command in R:
devtools::install_github("nicolaroberts/hdp", build_vignettes = TRUE)
This used to get compiled and installed fine when I had the R version 3.6.2 and gcc version 9.2.1 on an (Arch) Linux machine. After updating the system to R 4.0.0 and gcc 10.1.0, the installation fails with the following message:
* installing *source* package ‘hdp’ ...
** using staged installation
** libs
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-base.c -o R-base.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-conparam.c -o R-conparam.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-dp.c -o R-dp.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-hdp.c -o R-hdp.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-hdpMultinomial_iterate.c -o R-hdpMultinomial_iterate.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-multinomial.c -o R-multinomial.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-utils.c -o R-utils.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c randutils.c -o randutils.o
gcc -shared -L/usr/lib64/R/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -o hdp.so R-base.o R-conparam.o R-dp.o R-hdp.o R-hdpMultinomial_iterate.o R-multinomial.o R-utils.o randutils.o -L/usr/lib64/R/lib -lR
/usr/bin/ld: R-conparam.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: R-dp.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: R-hdp.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: R-hdpMultinomial_iterate.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: R-multinomial.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: R-utils.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: randutils.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R//make/shlib.mk:6: hdp.so] Error 1
ERROR: compilation failed for package ‘hdp’
The individual files are compiling fine, but the linking seems to fail. Any idea on how to go about debugging what is missing?
In case someone else runs into this issue: I manged to compile it by commenting all the references to the debug printing code. I commented all lines with rdebug* and DEBUG. These functions are mainly defined in R-utils.h. It still would be nice to find a better solution. There seems to be a circular definition of the DEBUG?
I had the same issue and ended up wrangling with the C code for several hours. My knowledge in C/C++ is very limited so perhaps there are better solutions but these changes worked for me.
Defining NODEBUG in R-utils.h after #ifndef NODEBUG and adding an extern to the declaration of DEGUB per below.
#ifndef NODEBUG
#define NODEBUG
extern int DEBUG;
Added int DEBUG to R-utils.c after #include "R-utils.h".

RcppEigen.h: No such file or directory during installation of ... RcppEigen on Centos 7

I'm not new to R but can't figure out what went wrong. I'm just trying to install RcppEigen package using install.packages('RcppEigen') and receive the above error.
The command below (issued by the installer) fails:
g++ -m64 -I/usr/include/R -DNDEBUG -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include -std=c++11 -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c RcppEigen.cpp -o RcppEigen.o
I have installed both R-Rcpp and R-Rcpp-devel version 0.12.12 from EPEL repository as well as eigen3-devel v 3.2.5 (not sure whether it is required but anyway ...)
I cloned RcppEigen from Github and tried to build in RStudio - the same error.
Makevars has PKG_CXXFLAGS = -I../inst/include but the compiler is invoked as below:
g++ -m64 -I/usr/include/R -DNDEBUG -I"/home/zer0hedge/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -std=c++11 -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c RcppEigen.cpp -o RcppEigen.o
For some reason, I had PKG_CXXFLAGS defined in $HOME/.R/Makevars. It erroneously overrided PKG_CXXFLAGS in Makevars in src directory of the package and prevented compilation of C++ files

Installation of rgdal fails in Gentoo with inverser.c include directive

I am trying to install rgdal (a dependency of gstat) in R on a Calculate Linux (effectively a generic Gentoo) clean installation. I have sci-libs/gdal installed. Here are the last few lines of output:
x86_64-pc-linux-gnu-g++ -I/usr/lib64/R/include -DNDEBUG -I/usr/include/gdal -I"/home/wjc721/R/x86_64-pc-linux-gnu-library/3.2/sp/include" -fpic -O2 -march=x86-64 -pipe -c OGR_write.cpp -o OGR_write.o
x86_64-pc-linux-gnu-g++ -I/usr/lib64/R/include -DNDEBUG -I/usr/include/gdal -I"/home/wjc721/R/x86_64-pc-linux-gnu-library/3.2/sp/include" -fpic -O2 -march=x86-64 -pipe -c gdal-bindings.cpp -o gdal-bindings.o
x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG -I/usr/include/gdal -I"/home/wjc721/R/x86_64-pc-linux-gnu-library/3.2/sp/include" -fpic -O2 -march=x86-64 -pipe -c init.c -o init.o
x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG -I/usr/include/gdal -I"/home/wjc721/R/x86_64-pc-linux-gnu-library/3.2/sp/include" -fpic -O2 -march=x86-64 -pipe -c inverser.c -o inverser.o
inverser.c:3:22: fatal error: projects.h: No such file or directory
#include <projects.h>
^
compilation terminated.
Existing answers on Stackoverflow are for Linux distributions other than Gentoo. They suggest installation of packages (in Debian) such as libgdal1h, libgdal1-dev, libproj-dev and gdal-bin, none of which exist in Gentoo.
Any help would be very much appreciated! It was working fine on the previous version of Calculate :(
Thanks,
Bill
Edit: I upgraded R from v3.2.2 to 3.3.2 and gdal from 2.0.2-r3 to 2.0.3. This did not help, the error is the same.
I encountered the same problem. Upgrading to proj-4.9.2 did the trick.

R install package Rcplex

I already follow INSTALL STEP at INSTALL
but something wrong happen when I install the package
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex.c -o Rcplex.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex_QCP.c -o Rcplex_QCP.o
Rcplex_QCP.c: In function 'Rcplex_QCP':
Rcplex_QCP.c:37:7: warning: unused variable 'trace' [-Wunused-variable]
int trace = INTEGER(getListElement(control,"trace"))[0];
^
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex_params.c -o Rcplex_params.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex_utils.c -o Rcplex_utils.o
C:/Rtools/mingw_32/bin/../lib/gcc/i686-w64-mingw32/4.9.3/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lcplex1263
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'Rcplex'
When you go to the package documentation at: https://cran.r-project.org/web/packages/Rcplex/index.html ... You make no mention of satisfying the system requirements:
SystemRequirements: IBM ILOG CPLEX libraries and headers
The linker that gcc uses, ld, cannot find the shared library for CPLEX. According to the INSTALL document, you need to verify that CPLEX_LIB_PATH is defined to point to the path where the CPLEX dll's are located. From your output, I'd venture
set CPLEX_LIB_PATH="C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/lib"
is what you need.

Resources