girke-lab / ChemmineOB

OpenBabel wrapper package for R
Other
9 stars 5 forks source link

Library not loaded: libopenbabel.5.dylib #19

Closed ktbaek closed 3 years ago

ktbaek commented 4 years ago

I get this error message repeatedly when trying to load "ChemmineOB" in R:

Error: package or namespace load failed for ‘ChemmineOB’:
 .onLoad failed in loadNamespace() for 'ChemmineOB', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/ChemmineOB/libs/ChemmineOB.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/ChemmineOB/libs/ChemmineOB.so, 10): Library not loaded: /usr/local/opt/open-babel/lib/libopenbabel.5.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/ChemmineOB/libs/ChemmineOB.so
  Reason: image not found

I have installed OpenBabel with Homebrew, and while there's indeed no /usr/local/opt/open-babel/lib/libopenbabel.5.dylib file, there is a libopenbabel.6.dylib file in that folder. It seems ChemmineOB should be looking for that file instead?

I use this R version: R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night" Copyright (C) 2019 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin15.6.0 (64-bit)

Can anybody help?

khoran commented 4 years ago

I'm not too familiar with macs, but I can give you some suggestions. Try setting a few different environment variables: OPEN_BABEL_INCDIR = path to header files OPEN_BABEL_LIBDIR = path to shared (.dylib) library file (/usr/local/optn/open-bable/lib) or LD_LIBRARY_PATH = path to dylib directory or DYLD_LIBRARY_PATH = path to dylib directory

adelenelai commented 4 years ago

Hi @ktbaek any luck?

I'm having the same issue, having also installed OpenBabel with Homebrew on Mac. I did some digging and it seems that Homebrew installs OpenBabel in /usr/local/Cellar/open-babel, not in opt. Correspondingly, the libopenbabel.5.dylib file it keeps looking for is not in /usr/local/opt/... but in /usr/local/Cellar/open-babel/3.0.0/share/openbabel/3.0.0/lib.

I tried several combinations of what @khoran suggested, both trying in the ~/.bashrc as:

export DYLD_LIBRARY_PATH=/usr/local/Cellar/open-babel/3.0.0/lib

or OPEN_BABEL_LIBDIR= or DYLD_LIBRARY_PATH=

export OPEN_BABEL_INCDIR = /usr/local/Cellar/open-babel/3.0.0/include/openbabel3/openbabel`

then reloading the terminal and my R, and also trying to set the system variables within R itself as:

Sys.setenv(OPEN_BABEL_INCDIR = "/usr/local/Cellar/open-babel/3.0.0/include/openbabel3/openbabel", DYLD_LIBRARY_PATH* = "/usr/local/Cellar/open-babel/3.0.0/lib")

*or LD_LIBRARY_PATH or OPEN_BABEL_LIBDIR

Each time, trying to load the library still gives the error:

Error: package or namespace load failed for ‘ChemmineOB’: .onLoad failed in loadNamespace() for 'ChemmineOB', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/ChemmineOB/libs/ChemmineOB.so': dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/ChemmineOB/libs/ChemmineOB.so, 10): Library not loaded: /usr/local/opt/open-babel/lib/libopenbabel.5.dylib Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/ChemmineOB/libs/ChemmineOB.so

which seems to indicate that it is still looking in /usr/local/opt (!!)

Any suggestions @khoran ?

khoran commented 3 years ago

You could try a command like: R CMD INSTALL --configure-args='--with-openbabel-include=... --with-openbabel-lib=...' ChemmineOB- ... .tgz This will bypass any environment variables, which may not be getting picked up for some reason, and set the paths directly. See the INSTALL file for more details.