This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: _dbm requires -lgdbm if gdbm is built as static libraries
Type: compile error Stage: resolved
Components: Build Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: ncoghlan, yan12125
Priority: normal Keywords: patch

Created on 2017-02-04 05:18 by yan12125, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
gdbm.patch yan12125, 2017-02-04 05:18
gdbm.patch yan12125, 2017-02-04 15:50 The correct patch, please ignore previous one
Messages (4)
msg286907 - (view) Author: (yan12125) * Date: 2017-02-04 05:18
In setup.py, _dbm links to gdbm_compat only. If gdbm is built as dynamic libraries, libgdbm_compat.so has a NEEDED flag for libgdbm.so, so both symbols in libgdbm and libgdbm_compat can be used. However, as static libraries does not provide such a flag, importing _dbm raises ImportError:

shell@ASUS_Z00E_2:/data/local/tmp $ python3.7m -c 'import _dbm'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: dlopen failed: cannot locate symbol "gdbm_errno" referenced by "/data/local/tmp/python3/usr/lib/python3.7/lib-dynload/_dbm.cpython-37m.so"...

gdbm_errno is a symbol in libgdbm.a.

gdbm manual [1] suggests linking to both libraries, too.

[1] http://www.gnu.org.ua/software/gdbm/manual/html_node/Compatibility.html
msg286908 - (view) Author: (yan12125) * Date: 2017-02-04 05:21
Add the developer who wrote this line (issue15044)
msg286971 - (view) Author: (yan12125) * Date: 2017-02-04 15:50
Sorry, -lgdbm should come after -lgdbm_compat, or symbols in libgdbm.a are still not resolved. I don't know why - linking is a magic :(
msg337012 - (view) Author: (yan12125) * Date: 2019-03-02 14:37
I gave up building gdbm as a static library. It brings more headache than benefits.
History
Date User Action Args
2022-04-11 14:58:42adminsetgithub: 73626
2019-03-02 14:37:49yan12125setstatus: open -> closed
resolution: wont fix
messages: + msg337012

stage: resolved
2017-02-04 15:50:03yan12125setfiles: + gdbm.patch

messages: + msg286971
2017-02-04 05:21:06yan12125setnosy: + ncoghlan
messages: + msg286908
2017-02-04 05:18:54yan12125create