girke-lab / ChemmineOB

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

Loading failure when installing #28

Closed AmiyaKirizi closed 1 year ago

AmiyaKirizi commented 1 year ago

Hi:

When I tried to install ChemmineOB on my institutional Mac (no root access), I find I am unable to properly install Here is the code i used in R to install, I use brew-installed openbabel 3.1.1 located at a custom location. BiocManager::install(pkgs = "ChemmineOB",INSTALL_opts = '--no-lock', configure.args = '--with-openbabel-include=/Users/xx/anaconda3/pkgs/openbabel-3.1.1-py310he467037_4/include/openbabel3 --with-openbabel-lib=/Users/xx/anaconda3/pkgs/openbabel-3.1.1-py310he467037_4/lib/openbabel/3.1.0') Here is the error code

** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
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 '/Users/lu.t/Library/R/arm64/4.2/library/ChemmineOB/libs/ChemmineOB.so':
  dlopen(/Users/lu.t/Library/R/arm64/4.2/library/ChemmineOB/libs/ChemmineOB.so, 0x000A): symbol not found in flat namespace (__ZN9OpenBabel10FastSearch11FindSimilarEPNS_6OBBaseERNSt3__18multimapIdmNS3_4lessIdEENS3_9allocatorINS3_4pairIKdmEEEEEEdd)
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/lu.t/Library/R/arm64/4.2/library/ChemmineOB’

I don't know what does it means to say the symbol not found in flat namespace. And here is the R version I used:

> R.Version()
$platform
[1] "aarch64-apple-darwin20"

$arch
[1] "aarch64"

$os
[1] "darwin20"

$system
[1] "aarch64, darwin20"

$status
[1] ""

$major
[1] "4"

$minor
[1] "2.0"

$year
[1] "2022"

$month
[1] "04"

$day
[1] "22"

$`svn rev`
[1] "82229"

$language
[1] "R"

$version.string
[1] "R version 4.2.0 (2022-04-22)"

$nickname
[1] "Vigorous Calisthenics"
martin-g commented 1 year ago

I am facing a similar error on Linux ARM64:

wget https://github.com/openbabel/openbabel/releases/download/openbabel-3-1-1/openbabel-3.1.1-source.tar.bz2
tar jxvf openbabel-3.1.1-source.tar.bz2
cd openbabel-3.1.1-source
mkdir build && cd build
cmake ..
make -j
export OPEN_BABEL_HOME="/home/biocbuild/openbabel-3.1.1"
cmake --install . --prefix $OPEN_BABEL_HOME
export OPENBABEL_LIBS="$OPEN_BABEL_HOME/lib"
export OPENBABEL_CFLAGS="-I$OPEN_BABEL_HOME/include/openbabel3 -L$OPENBABEL_LIBS"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OPENBABEL_LIBS

R CMD INSTALL ChemmineOB

Error:

* installing to library ‘/home/biocbuild/R/R-4.3.0/site-library’
* installing *source* package ‘ChemmineOB’ ...
** using staged installation
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for OPENBABEL... yes
checking for OPENBABEL... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘g++ (GCC) 10.3.1’
make: Nothing to be done for 'all'.
installing to /home/biocbuild/R/R-4.3.0/site-library/00LOCK-ChemmineOB/00new/ChemmineOB/libs
** R
** inst
** byte-compile and prepare package for lazy loading
in method for ‘copyToR’ with signature ‘"_p_std::char_traits<(char)>"’: no definition for class “_p_std::char_traits<(char)>”
in method for ‘copyToR’ with signature ‘"_p_std::pair<(unsigned int,unsigned int)>"’: no definition for class “_p_std::pair<(unsigned int,unsigned int)>”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::CharPtrLess"’: no definition for class “_p_OpenBabel::CharPtrLess”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::FptIndexHeader"’: no definition for class “_p_OpenBabel::FptIndexHeader”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::OBStereo"’: no definition for class “_p_OpenBabel::OBStereo”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::OBStereoUnit"’: no definition for class “_p_OpenBabel::OBStereoUnit”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::LineSearchType"’: no definition for class “_p_OpenBabel::LineSearchType”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::OBTetrahedralConfig"’: no definition for class “_p_OpenBabel::OBTetrahedralConfig”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::OBCisTransConfig"’: no definition for class “_p_OpenBabel::OBCisTransConfig”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::OBSquarePlanarConfig"’: no definition for class “_p_OpenBabel::OBSquarePlanarConfig”
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
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 '/home/biocbuild/R/R-4.3.0/site-library/00LOCK-ChemmineOB/00new/ChemmineOB/libs/ChemmineOB.so':
  /home/biocbuild/R/R-4.3.0/site-library/00LOCK-ChemmineOB/00new/ChemmineOB/libs/ChemmineOB.so: undefined symbol: _ZTIN9OpenBabel6OBBaseE
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/biocbuild/R/R-4.3.0/site-library/ChemmineOB’
khoran commented 1 year ago

@AmiyaKirizi Try changing your command to: BiocManager::install(pkgs = "ChemmineOB",INSTALL_opts = '--no-lock', configure.args = '--with-openbabel-include=/Users/xx/anaconda3/pkgs/openbabel-3.1.1-py310he467037_4/include/openbabel3 --with-openbabel-lib=/Users/xx/anaconda3/pkgs/openbabel-3.1.1-py310he467037_4/lib') , so just remove the 'openbabel/3.1.0' from the end of the lib path.

khoran commented 1 year ago

@martin-g Try setting these environment variables before running INSTALL:

OPEN_BABEL_INCDIR = $OPENBABEL_HOME/include/openbabel3 OPEN_BABEL_LIBDIR = $OPENBABEL_HOME/lib

See the INSTALL file for details.

You may also need to set these at runtime:

BABEL_DATADIR=$OPENBABEL_HOME/share/openbabel/3.1.0 BABEL_LIBDIR=$OPENBABEL_HOME/lib or BABEL_LIBDIR=<path to build dir>/lib

The structure of install/lib and build/lib directories is a little different.

martin-g commented 1 year ago

Thank you for your help, @khoran !

I was not able to get any success with the environment variables.

So I tried with the configure arguments:

$ R CMD INSTALL --configure-args='--with-openbabel-include=/home/biocbuild/openbabel-3.1.1/include/openbabel3 --with-openbabel-lib=/home/biocbuild/openbabel-3.1.1/lib' ChemmineOB
Warning: unknown option ‘--with-openbabel-lib=/home/biocbuild/openbabel-3.1.1/lib’
* installing to library ‘/home/biocbuild/R/R-4.3.0/site-library’
* installing *source* package ‘ChemmineOB’ ...
** using staged installation
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘g++ (GCC) 10.3.1’
g++ -std=gnu++17 -I"/home/biocbuild/R/R-4.3.0/include" -DNDEBUG -I/usr/include/openbabel3  -I/usr/include/eigen3  -DUSE_BOOST -DHAVE_EIGEN  -I/usr/local/include/eigen3 -I/usr/local/include/openbabel3  -I/home/biocbuild/openbabel-3.1.1/include/openbabel3  -I'/home/biocbuild/R/R-4.3.0/library/BH/include' -I'/home/biocbuild/R/R-4.3.0/site-library/Rcpp/include' -I'/home/biocbuild/R/R-4.3.0/site-library/zlibbioc/include' -I/usr/local/include    -fPIC  -g -O2  -c ChemmineOB.cpp -o ChemmineOB.o
g++ -std=gnu++17 -I"/home/biocbuild/R/R-4.3.0/include" -DNDEBUG -I/usr/include/openbabel3  -I/usr/include/eigen3  -DUSE_BOOST -DHAVE_EIGEN  -I/usr/local/include/eigen3 -I/usr/local/include/openbabel3  -I/home/biocbuild/openbabel-3.1.1/include/openbabel3  -I'/home/biocbuild/R/R-4.3.0/library/BH/include' -I'/home/biocbuild/R/R-4.3.0/site-library/Rcpp/include' -I'/home/biocbuild/R/R-4.3.0/site-library/zlibbioc/include' -I/usr/local/include    -fPIC  -g -O2  -c canonical.cpp -o canonical.o
g++ -std=gnu++17 -shared -L/home/biocbuild/R/R-4.3.0/lib -L/usr/local/lib -o ChemmineOB.so ChemmineOB.o canonical.o -L/usr/local/lib/openbabel3 -L/lib -lopenbabel -L/home/biocbuild/R/R-4.3.0/lib -lR
/usr/bin/ld: cannot find -lopenbabel
collect2: error: ld returned 1 exit status
make: *** [/home/biocbuild/R/R-4.3.0/share/make/shlib.mk:10: ChemmineOB.so] Error 1
ERROR: compilation failed for package ‘ChemmineOB’
* removing ‘/home/biocbuild/R/R-4.3.0/site-library/ChemmineOB’

Note the warning at the top: Warning: unknown option ‘--with-openbabel-lib=/home/biocbuild/openbabel-3.1.1/lib’

$ ls -la /home/biocbuild/openbabel-3.1.1/lib
total 4.8M
drwxr-xr-x 3 biocbuild biocbuild 4.0K Jun  2 10:09 cmake
lrwxrwxrwx 1 biocbuild biocbuild   16 Jun  2 10:09 libcoordgen.so -> libcoordgen.so.1
lrwxrwxrwx 1 biocbuild biocbuild   20 Jun  2 10:09 libcoordgen.so.1 -> libcoordgen.so.1.4.0
-rwxr-xr-x 1 biocbuild biocbuild 678K Jun  2 10:07 libcoordgen.so.1.4.0
lrwxrwxrwx 1 biocbuild biocbuild   13 Jun  2 10:09 libinchi.so -> libinchi.so.0
lrwxrwxrwx 1 biocbuild biocbuild   17 Jun  2 10:09 libinchi.so.0 -> libinchi.so.0.4.1
-rwxr-xr-x 1 biocbuild biocbuild 1.1M Jun  2 10:08 libinchi.so.0.4.1
lrwxrwxrwx 1 biocbuild biocbuild   17 Jun  2 10:09 libmaeparser.so -> libmaeparser.so.1
lrwxrwxrwx 1 biocbuild biocbuild   21 Jun  2 10:09 libmaeparser.so.1 -> libmaeparser.so.1.2.3
-rwxr-xr-x 1 biocbuild biocbuild 451K Jun  2 10:07 libmaeparser.so.1.2.3
lrwxrwxrwx 1 biocbuild biocbuild   17 Jun  2 10:09 libopenbabel.so -> libopenbabel.so.7
lrwxrwxrwx 1 biocbuild biocbuild   21 Jun  2 10:09 libopenbabel.so.7 -> libopenbabel.so.7.0.0
-rwxr-xr-x 1 biocbuild biocbuild 2.6M Jun  2 10:08 libopenbabel.so.7.0.0
drwxr-xr-x 3 biocbuild biocbuild 4.0K Jun  2 10:09 openbabel
drwxr-xr-x 2 biocbuild biocbuild 4.0K Jun  2 10:09 pkgconfig

I cloned ChemmineOB with git clone https://git.bioconductor.org/packages/ChemmineOB. This checks out the devel branch but looking into the contents of configure.ac it actually looks like https://github.com/girke-lab/ChemmineOB/blob/master/configure.ac (I see openbabel-3.0 in my local configure.ac)

At https://github.com/girke-lab/ChemmineOB/blob/devel/configure.ac#L15 (devel branch!) I see that it is for openbabel-2.0

Could our problems be that there is some change in OpenBabel 3.1 ?

martin-g commented 1 year ago

I've found the problem with the env vars! It was a stupid typo in export OPEN_BABEL_HOME ...

$ R CMD INSTALL ChemmineOB
* installing to library ‘/home/biocbuild/R/R-4.3.0/site-library’
* installing *source* package ‘ChemmineOB’ ...
** using staged installation
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking how to run the C preprocessor... gcc -E
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘g++ (GCC) 10.3.1’
g++ -std=gnu++17 -I"/home/biocbuild/R/R-4.3.0/include" -DNDEBUG -I/usr/include/openbabel3  -I/usr/include/eigen3  -DUSE_BOOST -DHAVE_EIGEN  -I/usr/local/include/eigen3 -I/usr/local/include/openbabel3  -I/home/biocbuild/openbabel-3.1.1/include/openbabel3  -I'/home/biocbuild/R/R-4.3.0/library/BH/include' -I'/home/biocbuild/R/R-4.3.0/site-library/Rcpp/include' -I'/home/biocbuild/R/R-4.3.0/site-library/zlibbioc/include' -I/usr/local/include    -fPIC  -g -O2  -c ChemmineOB.cpp -o ChemmineOB.o
g++ -std=gnu++17 -I"/home/biocbuild/R/R-4.3.0/include" -DNDEBUG -I/usr/include/openbabel3  -I/usr/include/eigen3  -DUSE_BOOST -DHAVE_EIGEN  -I/usr/local/include/eigen3 -I/usr/local/include/openbabel3  -I/home/biocbuild/openbabel-3.1.1/include/openbabel3  -I'/home/biocbuild/R/R-4.3.0/library/BH/include' -I'/home/biocbuild/R/R-4.3.0/site-library/Rcpp/include' -I'/home/biocbuild/R/R-4.3.0/site-library/zlibbioc/include' -I/usr/local/include    -fPIC  -g -O2  -c canonical.cpp -o canonical.o
g++ -std=gnu++17 -shared -L/home/biocbuild/R/R-4.3.0/lib -L/usr/local/lib -o ChemmineOB.so ChemmineOB.o canonical.o -L/usr/local/lib/openbabel3 -L/home/biocbuild/openbabel-3.1.1/lib -lopenbabel -L/home/biocbuild/R/R-4.3.0/lib -lR
installing to /home/biocbuild/R/R-4.3.0/site-library/00LOCK-ChemmineOB/00new/ChemmineOB/libs
** R
** inst
** byte-compile and prepare package for lazy loading
in method for ‘copyToR’ with signature ‘"_p_std::char_traits<(char)>"’: no definition for class “_p_std::char_traits<(char)>”
in method for ‘copyToR’ with signature ‘"_p_std::pair<(unsigned int,unsigned int)>"’: no definition for class “_p_std::pair<(unsigned int,unsigned int)>”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::CharPtrLess"’: no definition for class “_p_OpenBabel::CharPtrLess”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::FptIndexHeader"’: no definition for class “_p_OpenBabel::FptIndexHeader”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::OBStereo"’: no definition for class “_p_OpenBabel::OBStereo”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::OBStereoUnit"’: no definition for class “_p_OpenBabel::OBStereoUnit”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::LineSearchType"’: no definition for class “_p_OpenBabel::LineSearchType”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::OBTetrahedralConfig"’: no definition for class “_p_OpenBabel::OBTetrahedralConfig”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::OBCisTransConfig"’: no definition for class “_p_OpenBabel::OBCisTransConfig”
in method for ‘copyToR’ with signature ‘"_p_OpenBabel::OBSquarePlanarConfig"’: no definition for class “_p_OpenBabel::OBSquarePlanarConfig”
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (ChemmineOB)
martin-g commented 1 year ago

I found the issue with --configure-args too. It must be:

R CMD INSTALL --configure-args='--with-openbabel-lib=/home/biocbuild/openbabel-3.1.1/lib' --configure-args='--with-openbabel-include=/home/biocbuild/openbabel-3.1.1/include/openbabel3' ChemmineOB

i.e. one --configure-args='...' per argument.

khoran commented 1 year ago

@martin-g Great, glad you got it to work. Sorry if my typo threw you off!