R Packages Fail to Compile with gcc
Modify your PATH to make sure that a gcc compiler more recent than gcc 3.2 is found.
If necessary, create a link to the recent one (assuming you want to still keep gcc 3.2 around):
mkdir $HOME/bin
ln -s /usr/bin/gcc-VERSION $HOME/bin/gcc
export PATH=$HOME/bin:$PATH
# proceed to your normal installation
VERSION indicates the gcc version of the compiler normally used in your system
Error installing old packages in R
You should install Rtools which contains resources needed to build packages in R under Microsoft Windows :
https://cran.r-project.org/bin/windows/Rtools/
After installing, you should see it under your PATH variable:
Sys.getenv("PATH")
Override Specific Compiler Flags When Installing R Packages
You can edit your .R/Makevars file and append the desired flags using the +=
operator, e.g.
CFLAGS+= -O3 -Wall -mtune=native -march=native
The latter flag is used if there is a conflict, as you said in your comment below. In terms of compiling from source, you can do this via install.packages()
, e.g.
install.packages("package_name", type = "source")
How to avoid cannot find -lR for R Package installation on windows
You are making three mistakes:
- You should not install rtools under
program files
or any other path with a space. - You are using
BINPREF
wrong, causing the 64-bit toolchain to be used on 32-bit. - The mingw gcc dirs should not be on the PATH. Only the
bin
dir (bash
andmake
) should be.
Recommended setup:
It is highly recommended to install rtools in the default location C:\Rtools\
. This is the only configuration that is widely tested.
In this case you only need to make put C:\Rtools\bin
is on the PATH in order to compile packages. R will automatically use the correct compilers on 32-bit and 64-bit.
With non-default Rtools location:
If you really must install rtools in a non standard location, you can set BINPREF
to a pattern that includes $(WIN)
that gets expanded to the correct path for example like so:
Sys.setenv(BINPREF="C:/YourRtoolsPath/mingw_$(WIN)/bin/")
When make
invokes the compiler, $(WIN)
gets substituted by either 32
or 64
which should then resolve to the correct path of the respective toolchain.
Related Topics
Add a Constant Value to All Rows in a Dataframe
How to Use R to Create a Word Co-Occurrence Matrix
Looping Over Combinations of Regression Model Terms
How to Create a Dropdown List in a Shiny Table Using Datatable When Editing the Table
Error in As.Double(Y):Cannot Coerce Type 'S4' to Vector of Type 'Double'
Character "|" in Strsplit Function (Vertical Bar/Pipe)
Pivot Wider Produces Nested Object
Warnings When Running an Lmer in R
Ggplot Annotation in Fixed Place in the Chart
Convert Byte Encoding to Unicode
Http Error 400 on Google_Elevation() Call
Format a Vector of Rows in Italic and Red Font in R Dt (Datatable)
Ggplot2 Force Y-Axis to Start at Origin and Float Y-Axis Upper Limit
R: Get the Min/Max of Each Item of a Vector Compared to Single Value
How to Place an Identical Smooth on Each Facet of a Ggplot2 Object
Calculate Row Means Based on (Partial) Matching Column Names