Hanjun-Dai / pytorch_structure2vec

pytorch implementation of structure2vec (https://arxiv.org/abs/1603.05629)
MIT License
305 stars 76 forks source link

Undefined symbol in libmol.so #2

Closed hgascon closed 6 years ago

hgascon commented 6 years ago

Hi @Hanjun-Dai, I have installed rdkit from source and was able to compile the harvard cep. However, when I try to run the example experiment, loading libmol.so in mol_lib.py line 12:

self.lib = ctypes.CDLL('%s/build/dll/libmol.so' % dir_path)

returns an undefined symbol error:

OSError: ./build/dll/libmol.so: undefined symbol: _ZN5RDKit17SmilesMolSupplierC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_iibb

Any hints here? Thanks!

Hanjun-Dai commented 6 years ago

Hi there, it seems the error is related to RDKIT, since the function 'SmilesMolSupplier...' belongs to rdkit.

To make several things clear: 1) which version of rdkit did you use? I used https://github.com/rdkit/rdkit/releases/tag/Release_2017_09_1

2) In the Makefile, the include path is set to $RDBASE/Code, and the lib path is set to $RDBASE/lib So make sure the lib files are there.

Let me know if that works.

hgascon commented 6 years ago

I used rdkit from the repository. Now I have tried with the Release_2017_09_1 version and it compiles without errors. However, I compile harvard_cep and get the same error when executing for example:

python mol_lib.py

What version of boost have you used?

Hanjun-Dai commented 6 years ago

I was using boost 1.64.0, but I don't think it is due to boost c++.

Also is the error reported during compilation or execution?

hgascon commented 6 years ago

Execution.

This is the output from ldd build/dll/libmol.so:

linux-vdso.so.1 =>  (0x00007ffc80359000)
libRDKitGraphMol.so.1 => [...]/rdkit-Release_2017_09_1/lib/libRDKitGraphMol.so.1 (0x00007f57385d9000)
libRDKitRDGeneral.so.1 => [...]/rdkit-Release_2017_09_1/lib/libRDKitRDGeneral.so.1 (0x00007f57383bb000)
libRDKitFileParsers.so.1 => [...]/rdkit-Release_2017_09_1/lib/libRDKitFileParsers.so.1 (0x00007f57380e3000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f5737d44000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5737b2d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5737763000)
libRDKitRDGeometryLib.so.1 => [...]/rdkit-Release_2017_09_1/lib/libRDKitRDGeometryLib.so.1 (0x00007f5737537000)
libboost_thread.so.1.65.1 => [...]/boost_1_65_1/stage/lib/libboost_thread.so.1.65.1 (0x00007f573730e000)
libboost_system.so.1.65.1 => [...]/boost_1_65_1/stage/lib/libboost_system.so.1.65.1 (0x00007f573710a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5736eec000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5736be3000)
libRDKitSmilesParse.so.1 => [...]/rdkit-Release_2017_09_1/lib/libRDKitSmilesParse.so.1 (0x00007f5736973000)
/lib64/ld-linux-x86-64.so.2 (0x000055fde423a000)
libRDKitDataStructs.so.1 => [...]/rdkit-Release_2017_09_1/lib/libRDKitDataStructs.so.1 (0x00007f573665d000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5736454000)
hgascon commented 6 years ago

Ok, problem solved. Apparently, as described here, ctypes does not use LD_LIBRARY_PATH in linux and the solution is to pass the linker the relative path of the libraries needed:

-Wl,-rpath='.',-rpath='./another/relative/rpath'
Hanjun-Dai commented 6 years ago

That's great! Thanks for investigating into the issue!

But it seems your linker tells the right path already. I've added -L$RDBASE/lib to the Makefile, it should be able to find the right file. Maybe you can check whether your desired rdkit lib has highest priority in LD_LIBRARY_PATH