3

I have uploaded the version of R to 4.0.2 (2020-06-22). After installing the gmm package when I require it I got the message below. I have also taken this message for the other packages like TropFishR. I have Xcode 10.3 . I reinstalled R studio and R several times. thank you very much for your time.

Error message:

Error: package or namespace load failed for ‘gmm’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so, 6): Library not loaded: /usr/local/gfortran/lib/libgomp.1.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so
  Reason: image not found


session info:

 version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils    
[5] datasets  methods   base     

other attached packages:
[1] sandwich_2.5-1

loaded via a namespace (and not attached):
[1] zoo_1.8-8       compiler_4.0.2 
[3] tools_4.0.2     grid_4.0.2     
[5] lattice_0.20-41
pomatomus
  • 121
  • 1
  • 10
  • How exactly did you install the package? Did you install from binary or source? What messages did you get when you installed it? Try installing again and keeping track of the output. – MrFlick Aug 20 '20 at 19:46
  • I installed with 'install.packages("gmm")'. I did not get any message . Everything looked like normal. – pomatomus Aug 20 '20 at 19:50
  • A common way to prevent library issues when you install R is to use miniconda. See this good answer how to run R with miniconda https://stackoverflow.com/questions/70410968/is-it-possible-to-install-r-in-miniconda – Stereo Oct 11 '22 at 08:17

4 Answers4

9

The problem is caused because Library not loaded: /usr/local/gfortran/lib/libgomp.1.dylib is missed.

To solve it, I went to this Github release page, downloaded gfortran-10.2-Catalina.dmg, and installed it. Then I can finally load gmm package in R.

user14675774
  • 91
  • 1
  • 2
2

On MacOS 13, download this file, and build a hard link to /usr/local/gfortran/lib/libgomp.1.dylib in /opt/R/arm64/gfortran/lib, e.g., using the following command:

sudo ln libgomp.1.dylib /opt/R/arm64/gfortran/lib/libgomp.1.dylib 

maybe the directory /gfortran/lib is required to be built manually. Hope helpful~

Minux
  • 51
  • 1
  • 8
1

Using this answer I found a (temporary) way to fix this issue without messing around with installations.

Finding the file

It seems that the program can't find libgomp.1.dylib, however, your system may already have this file installed. Using:

locate libgomp.1.dylib

you get a list of places where this library has been found. If you are running this command for the first time, you may have to run another command first to create the index.

For me, this was:

/usr/local/Cellar/gcc/12.1.0/lib/gcc/current/libgomp.1.dylib

However, it might be different on your system.

If nothing is returned, you may need to install gfortran on your system, e.g. using brew install gcc.

Linking the file

My error message showed me some places where it tried to look for the file, one of which was in my user directory:

/Users/overground/lib

So, using ln, create a link from this directory to the file you have found in the previous step. First, ensure that the lib folder exists in your user directory. Then, link the files with:

ln /usr/local/Cellar/gcc/12.1.0/lib/gcc/current/libgomp.1.dylib /Users/overground/lib

Replace the first file path with the file path you have found in the first step, and the username in the second path. Now, you should be able to see the file in the lib directory.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
overground
  • 113
  • 6
0

This would sound crazy, but I had the same problem running a bash script (say masterPipeline.sh) that I wrote. When I wrote that script it was working fine, however a couple of days ago I got this error:

Error: package or namespace load failed for ‘stats’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/hemiptero/lib/R/library/stats/libs/stats.so':

The issue came after masterPipeline.sh invoke R to make a subroutine (R < ./scripts/measure2sd.r --no-save) but when I type that command by myself in the terminal I don't get the error.

So, I don't know how but I get with the idea of running my script as superuser.

sudo masterPipeline.sh   

It works!

So maybe running R as superuser would works for those working on linux

  • Great that this solved the issue for you. The problem you are facing is related to a different library and a different installation path. Look at the error message. The situation is also very different. Try keeping answers aligned with the question of the OP. See https://stackoverflow.com/help/how-to-answer – Stereo Oct 11 '22 at 08:16