pomatomus
pomatomus

Reputation: 263

Error: package or namespace load failed for ‘gmm’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object

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

Upvotes: 4

Views: 10267

Answers (4)

Minux
Minux

Reputation: 49

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~

Upvotes: 2

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

Upvotes: 0

overground
overground

Reputation: 113

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.

Upvotes: 1

user14675774
user14675774

Reputation: 91

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.

Upvotes: 9

Related Questions