# Why is R in RStudio attempting to build package binaries with \`g++-7\`?

**URL:** <https://ask.cyberinfrastructure.org/t/why-is-r-in-rstudio-attempting-to-build-package-binaries-with-g-7/3121>\
**Category:** University of Alabama at Birmingham\
**Tags:** r, compiling, rstudio\
**Created:** [April 22, 2024, 5:27pm UTC](https://ask.cyberinfrastructure.org/t/why-is-r-in-rstudio-attempting-to-build-package-binaries-with-g-7/3121 "2024-04-22T17:27:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wwarr](https://ask.cyberinfrastructure.org/letter_avatar_proxy/v4/letter/w/3be4f8/32.png) [@wwarr](https://ask.cyberinfrastructure.org/u/wwarr)\
**Post date:** [April 22, 2024, 5:27pm UTC](https://ask.cyberinfrastructure.org/t/why-is-r-in-rstudio-attempting-to-build-package-binaries-with-g-7/3121/1 "2024-04-22T17:27:09Z")

</div>

When I attempt to install certain packages (e.g., `glmnet`) for R within RStudio, I get an error like `g++-7: command not found`.

Why is this occurring and what can be done about it?

---

<div class="post-metadata">

**Author:** ![wwarr](https://ask.cyberinfrastructure.org/letter_avatar_proxy/v4/letter/w/3be4f8/32.png) [@wwarr](https://ask.cyberinfrastructure.org/u/wwarr)\
**Post date:** [April 22, 2024, 5:27pm UTC](https://ask.cyberinfrastructure.org/t/why-is-r-in-rstudio-attempting-to-build-package-binaries-with-g-7/3121/2 "2024-04-22T17:27:38Z")

</div>

## Description

The error `g++-7: command not found` tells us R is using an unexpected command to build the package on your system. The typical command for building packages written in C++ on Linux systems is `g++`, without the trailing `-7`.

On our system, we found that this error is caused by a line in an unexpected file. The file is `~/.R/Makevars` and contains the following line.

```auto
CXX17 = g++-7 -std=gnu++17 -fPIC

```

The line causes the build tool `make` to use the `g++-7` executable instead of the typical `g++` whenever C++17 is being compiled. The `g++-7` executable doesn’t exist on our system, hence the error `command not found`.

## Resolution

To resolve the issue, delete the unexpected file using `rm ~/.R/Makevars`.

## Resources used to troubleshoot the originating issue

- [Compilation error installing R package glmnet - Stack Overflow](https://stackoverflow.com/questions/64031393/compilation-error-installing-r-package-glmnet)
