Error: package ‘gmm’ could not be loaded

Hi, I am trying to load the tmvtnorm library but I keep getting an error (see below) and don't know what to do. The package gmm appears in the system library but when I select it the same error appears. I couldn't find a solution and would appreciate any help.

> library(tmvtnorm)
Loading required package: mvtnorm
Loading required package: Matrix
Loading required package: stats4
Loading required package: gmm
Loading required package: sandwich
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
Error: package ‘gmm’ could not be loaded
1 Like

What output message you get if you try to reinstall gmm?

install.packages("gmm")
> install.packages("gmm")
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/gmm_1.6-5.tgz'
Content type 'application/x-gzip' length 1360675 bytes (1.3 MB)
==================================================
downloaded 1.3 MB


The downloaded binary packages are in
	/var/folders/p9/6j3mf3ts3sd37207n99h3f840000gn/T//RtmpsvOgEz/downloaded_packages
> library(tmvtnorm)
Loading required package: gmm
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
Error: package ‘gmm’ could not be loaded

I don't understand why it does not load gmm. I checked and gmm is in the location it says it cannot load it from:
'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so'

I suspect there is a compatibility issue with your fortran compiler but that is macOS specific and I'm not a mac user so I can't help you any further with that. I hope some of the macOS people here could be able to help you.

Thank you! I hope there will be someone able to help me.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.