twmht / python-rocksdb

Python bindings for RocksDB
BSD 3-Clause "New" or "Revised" License
276 stars 90 forks source link

pybind11 undefined symbol _ZN7rocksdb22GetLengthPrefixedSliceEPKc in old gcc #72

Open TomGoBravo opened 5 years ago

TomGoBravo commented 5 years ago

I built the pybind11 branch in a container following the instructions at https://github.com/twmht/python-rocksdb/tree/pybind11 :

git clone https://github.com/twmht/python-rocksdb.git --recursive -b pybind11
cd python-rocksdb
python setup.py install

but when a simple test fails:

# python
Python 3.6.2 (default, Oct 17 2017, 21:26:29) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyrocksdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/srv/venvs/service/trusty/service_venv_python3.6/lib/python3.6/site-packages/python_rocksdb-1.0-py3.6-linux-x86_64.egg/pyrocksdb/__init__.py", line 1, in <module>
    from .pyrocksdb import *
ImportError: /srv/venvs/service/trusty/service_venv_python3.6/lib/python3.6/site-packages/python_rocksdb-1.0-py3.6-linux-x86_64.egg/pyrocksdb/pyrocksdb.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN7rocksdb22GetLengthPrefixedSliceEPKc

readelf agrees it is UND:

readelf -Ws /srv/venvs/service/trusty/service_venv_python3.6/lib/python3.6/site-packages/python_rocksdb-1.0-py3.6-linux-x86_64.egg/pyrocksdb/pyrocksdb.cpython-36m-x86_64-linux-gnu.so |grep GetLengthPrefixedSlice
   280: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND ZN7rocksdb22GetLengthPrefixedSliceEPKc
  5335: 000000000023ba00   153 FUNC    WEAK   DEFAULT   11 ZN7rocksdb22GetLengthPrefixedSliceEPNS_5SliceES1_

I'm guessing the linker includes it because the function is extern in lib/rocksdb/include/rocksdb/memtablerep.h but I can't work out how to make it not include it or get the line from .pyrocksdb import * to not import it.

This problem appears in the container with ancient gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4 but not gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516.

I'm creating this issue to help anybody else who bumps into it. Sorry, no solution yet beyond upgrading gcc.