10

on a current macos system with the latest brew system (for gcc and other utilities), important packages like lmtest no longer install.

the error says the emutls_w library is not found.

Answer follows.

3 Answers 3

17

although the following works, too, a better solution is probably brew reinstall gcc first and see if it works.

the problem is that the current brew system seems to still use an older gcc version, that refers to itself as aarch64-apple-darwin21/ (maybe only when installed earlier). the R packages want what is relevant to the current version of macos, which is aarch64-apple-darwin22 (see uname -a).

a nasty workaround is to

$ sudo bash
# pushd /opt/homebrew/opt/gcc/lib/gcc/current/gcc/
# ln -s aarch64-apple-darwin21 aarch64-apple-darwin22 

then install what you need (in another terminal), and then

# rm aarch64-apple-darwin22
Sign up to request clarification or add additional context in comments.

3 Comments

for me the reinstallation of gcc worked!
@Ivo Welch, I suggest that you update the answer to suggest reinstalling gcc first which seems to work for many (including myself) and if that does not work then do the "nasty" workaround.
Reinstallation of gcc didn't work for me, the workaround did but it seems there is a typo, with 21 and 22 inverted in both command line code. By the way for my current version of macos it's aarch64-apple-darwin24 and not 22, so the actual lines of code I used were ln -s aarch64-apple-darwin24 aarch64-apple-darwin21 and rm aarch64-apple-darwin21
4

brew reinstall gcc did not work for me. I tried brew uninstall gcc && brew install gcc, which did not solve the issue either.

I had to edit my ~/.R/Makevars file and add -L/opt/homebrew/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/aarch64-apple-darwin24/14/ to LDFLAGS.

3 Comments

For reference, the Cellar location varies on different computers, and brew --cellar prints the folder path
Modifying the Makevars file with the additional LDFLAGS path worked for me too.
This worked for me, but I had to be less specific-L/usr/local/Cellar/gcc/15.2.0/lib/gcc/current When I included more of the path it found emutls_w but could no longer find gfortran (annoying). Thanks for your help!
0

I was able to install the required files through `macrtools`:

# install.packages("remotes")
remotes::install_github("coatless-mac/macrtools")
macrtools::gfortran_install()

This did not require me to change the `Makevars` file.

To install all tools run:

macrtools::macos_rtools_install()

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.