g++ not found when using install_github - r

I am trying to install an r-package via github via devtools::install_github('package_name')
I get the following error: "sh: g++ not found" and "ERROR: compilation failed for package 'package_name' "
Question: What do I need to do in order to have/find g++?
=========================================================
Extra information:
Windows 8.1 OS
R version 4.1.0
devtools version 2.4.2
rtools 40 installed (find_rtools() -> TRUE)

Related

Installation of r packages failed with the same error "GLIBCXX_3.4.29' not found"

When I tried to install r package "osmdata" (or any other package) with command
install.packages("osmdata")
it failed with error
"GLIBCXX_3.4.29' not found (required by /home...R/x86_64-unknown-linux-gnu-library/4.2/00LOCK-osmdata/00new/osmdata/libs/osmdata.so)
host system is debian, r is installed using package manager Guix.
The error means: osmdata.so was compiled with g++ version 11.1.0 (ABI mapping of GLIBCXX to g++ version is documented here), but the version of libstdc++.so.6 installed on the system is older, and doesn't provide GLIBCXX_3.4.29.
You need to get a version of osmdata.so appropriate for your system, or you need to build it from source, or you need to update your libstdc++.so.6.
P.S. Your question has nothing to do with glibc.
I solved it by installing package r-guix-install from Guix package manager and using this command
guix.install::guix.install("osmdata")

nloptr version 1.2.1 installation on Window 10: error #include "nlopt.h"

I need to install nloptr version 1.2.1 on Windows 10. Here is my code:
library("devtools")
install_version("nloptr", version = "1.2.1", repos = "http://cran.us.r-project.org")
And here is extract of error message:
init_nloptr.c:35:10: fatal error: nlopt.h: No such file or directory
#include "nlopt.h"
^~~~~~~~~
compilation terminated.
Any work around?
In fact, when installing {nloptr} from source on Windows OS, 'NLopt' is required. See the description from its github source:
For this to work on Windows, you need to have Rtools and NLopt installed, and set an environment variable NLOPT_HOME with the location of the NLopt library.
This can be done through RTools. Just open "Rtools Bash" program and execute these lines:
pacman -Sy
pacman -S mingw-w64-{i686,x86_64}-nlopt
Note: pacman -Sy is required only for refreshing Rtools packages for the first time use of "pacman".
For more information, see the official instructions of pacman.

R package data.table fails to install/compile on system with R 3.5.1

I'm trying to reinstall data.table with:
install.packages("data.table")
And I'm getting the following compile error:
forder.c: In function ‘range_str’:
forder.c:296: error: expected end of line before ‘update’
make: *** [forder.o] Error 1
ERROR: compilation failed for package ‘data.table’
The package I'm getting from cran is: data.table_1.12.0.tar.gz
Which should be a version that works with 3.5, unlike the issues with data.table 1.10
The system this is on is RHEL 6.9 + I also already updated gcc via yum.
R versions are also up2date from yum: R-core-3.5.1-1.el6.x86_64 R-core-devel-3.5.1-1.el6.x86_64
Everything I could find on google for this was either related to Rtools (Windows) or the older version 1.10, this seems like something else.
You can install an older version of data.table on EL6. 1.11.4 works; I'm not sure which, if any, newer versions do.
require(devtools)
install_version("data.table", version = "1.11.4")
More on installing older versions of packages: https://support.rstudio.com/hc/en-us/articles/219949047-Installing-older-versions-of-packages
The in the error message mentioned line is:
#pragma omp atomic update
which is functionality that is apparently not available in GCC before version 4.7 and on RedHat 6.9 the highest I get from standard repos is 4.4.7 at the moment.
Means I need a newer compiler, which can handle this openmp functionality.
I had the same error when installing data.table with R 3.5.0
On a CentOS 6.10 (which has gcc and g++ version 4.4.7), here is how I was able to install data.table:
yum install devtoolset-6
scl enable devtoolset-6 bash
now if you do: `which gcc` -v , you should see a higher gcc version
R
to start R 3.5.0
install.packages("data.table")
now I was able to install data.table

can't install the newest version gganimate package as if dependency 'transformr' is not available

I am using the newest software versions:
R 3.5.1, R Studio 1.1.456, Rtools 3.5
And I am getting the following error message:
c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o transformr.dll tmp.def RcppExports.o align_rings.o sf_packing.o triangulate.o -LD:/R/R-35~1.1/bin/x64 -lR
installing to D:/R/R-3.5.1/library/transformr/libs/x64
** R
** byte-compile and prepare package for lazy loading
Warning: S3 methods '$.bbox', '$.crs', '$<-.sf', '[.sf', '[.sfc', '[<-.sfc', '[[<-.sf', 'st_agr<-.sf', 'st_crs<-.sf', 'st_crs<-.sfc', 'st_geometry<-.data.frame', 'st_geometry<-.sf', 'Ops.crs', 'Ops.sfc', 'Ops.sfg', 'Ops.sgbp', 'aggregate.sf', 'as.data.frame.sf', 'as.data.frame.sfc', 'as.data.frame.sgbp', 'as.matrix.sfg', 'as.matrix.sgbp', 'c.sfc', 'c.sfg', 'cbind.sf', 'dim.sgbp', 'format.sfc', 'format.sfg', 'head.sfg', 'identify.sf', 'identify.sfc', 'is.na.bbox', 'is.na.crs', 'merge.sf', 'plot.sf', 'plot.sfc_CIRCULARSTRING', 'plot.sfc_GEOMETRY', 'plot.sfc_GEOMETRYCOLLECTION', 'plot.sfc_LINESTRING', 'plot.sfc_MULTILINESTRING', 'plot.sfc_MULTIPOINT', 'plot.sfc_MULTIPOLYGON', 'plot.sfc_POINT', 'plot.sfc_POLYGON', 'plot.sfg', 'print.bbox', 'print.crs', 'print.sf', 'print.sf_layers', 'print.sfc', 'print.sfg', 'print.sgbp', 'rbind.sf', 'rep.sfc', 'st_agr.character', 'st_agr.default', 'st_agr.factor', 'st_agr.sf', 'st_as_binary.sfc', 'st_as_binary.sfg', 'st_as_grob.CIRCULARSTRING', 'st_as_grob.COMPOUN [... truncated]
Error in library.dynam(lib, package, package.lib) :
DLL 'sf' not found: maybe not installed for this architecture?
ERROR: lazy loading failed for package 'transformr'
* removing 'D:/R/R-3.5.1/library/transformr'
In R CMD INSTALL
Installation failed: Command failed (1)
"D:/R/R-35~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore \
--quiet CMD INSTALL \
"C:/Temp/RtmpeE3VDN/devtools22dc79ce1d1/thomasp85-gganimate-ef2e717" \
--library="D:/R/R-3.5.1/library" --install-tests
ERROR: dependency 'transformr' is not available for package 'gganimate'
* removing 'D:/R/R-3.5.1/library/gganimate'
In R CMD INSTALL
Installation failed: Command failed (1)
Can you give me a solution?
I had same issue, I reinstalled tranformR, Rtools and added C:\Rtools\bin, C:\Rtools\mingw_64\bin to the environment paths. Restarted R and it was working. (note:- make sure Rtools is installed in C:)
Thx for Roland's suggested.because my English is poor.I can't understand his comments. and according to his suggestion, I check transformR's imports packcage. according to the error message as :"DLL 'sf' not found: maybe not installed for this architecture? " I check the sf package at frist. it can't open. so I confrimed the really issue is here.I deleted the package and reinstall it sucessfully, and then reinstall transformR sucessfully. and then reinstall gganimate package sucessfully. all problem had been sloved. and now I still not understand the word "as binaries" what mean it is.although it is not important. Thx Roland again.

Errors installing RForge version of xts package for R on OSX

The latest version of xts on CRAN is 0.7-5. But I'd like to try out the blotter package, for which xts >= 0.7.6.17 is required. To get this latest version, I first I downloaded the .tgz file from RForge and tried:
[Downloads]$ R CMD INSTALL xts_0.7-6.17.tgz
WARNING: ignoring environment value of R_HOME
* installing to library ‘/Library/Frameworks/R.framework/Resources/library’
* installing *binary* package ‘xts’ ...
* DONE (xts)
After launching R console, I typed require(xts) and got this:
> require(xts)
Loading required package: xts
Loading required package: zoo
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so':
dlopen(/Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so, 6): Library not loaded: /usr/local/lib/libgfortran.2.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so
Reason: image not found
In addition: Warning message:
package 'xts' was built under R version 2.12.2
I reverted to the CRAN version by downloading that file and running this again:
[Downloads]$ R CMD INSTALL xts_0.7-5.tgz
WARNING: ignoring environment value of R_HOME
* installing to library ‘/Library/Frameworks/R.framework/Resources/library’
* installing *binary* package ‘xts’ ...
* DONE (xts)
Opening R console and typing in require(xts):
> require(xts)
Loading required package: xts
Loading required package: zoo
>
All is well again, except I need to RForge version to get blotter installed.
NOTE: I'm running OS X (10.6.6)
UPDATE: all is NOT well. Now I can't get the CRAN xts version to load properly.
UPDATE #2: I got my old xts back by running install.packages("xts", repo="http://cran.r-project.org"). Actually, I ran it for "quantmod" and "TTR" as well because all manner of mysterious breaking was occurring.
UPDATE #3: Following Dirk's recommendation in comments below, I've attempted to compile from source on OS X and was met with
make: gfortran: No such file or directory
So after installing from the link at http://www.macresearch.org/xcode_gfortran_plugin_update, I'm now faced with a new error complaining about the -arch flag:
gfortran -arch i386 -fPIC -g -O2 -c period.max.f -o period.max.o
f951: error: unrecognized command line option "-arch"
UPDATE #4: I installed the wrong fortran compiler in UPDATE #3. Don't use that compiler for R packages.
If you are using R on the Mac OS X platform, then it's good to know the mechanics of installing from source, as Mac binaries are sometimes slow to make it to repositories. The R eco-system is Ubuntu and SVN. Someday it may morph to OS X and Git (we can hope, no?)
Before you start installing from source, you need to make sure you have Xcode installed.
http://developer.apple.com/technologies/tools/xcode.html
Then you need to have a fortran compiler, which doesn't come with Xcode. The good news is that there is a place devoted to fortran compilers on OS X for R users.
http://r.research.att.com/tools/
Once this is installed and configured properly, you need to get the cutting-edge version of xts from RForge from here: (Thanks Dirk)
http://r-forge.r-project.org/src/contrib/xts_0.7-6.17.tar.gz
Finally, simply run the following from command-line in terminal:
[Downloads]$ R CMD INSTALL xts_0.7-6.17.tar.gz
NOTE: tar.gz is the extension for source files while .tgz is the extension for Mac binaries.

Resources