Symbol not found: error while using ibm_db library in Python

Question:

I am using Monterey MacOS and Python 3.10. While running this sample code:

from ibm_db import connect
from ibm_db import fetch_assoc
from ibm_db import tables

connection = connect('DATABASE=<DATABASE>;'
                     'HOSTNAME=<HOSTNAME>;'  
                     'PORT=<PORT>;'
                     'PROTOCOL=<PROTOCOL>;'
                     'UID=<UID>;'
                     'PWD=<PWD>;', '', '')

I am getting error:

ImportError: dlopen(../lib/python3.10/site-packages/ibm_db.cpython-310-darwin.so, 0x0002): Symbol not found: (___cxa_throw_bad_array_new_length)
  Referenced from: '../lib/python3.10/site-packages/clidriver/lib/libdb2.dylib'
  Expected in: '/usr/lib/libstdc++.6.dylib'

Followed one of the solutions suggested in SO as:

export DYLD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/clidriver/lib

but didn’t work. Works fine on Windows machine but not working on latest MacOS. Some suggested to place libstdc++.6.0.9.dylib in /usr/lib but can’t do because of the permission issues.

Asked By: gd1

||

Answers:

Please use the python ibm_db issues website at https://github.com/ibmdb/python-ibmdb/issues , becuse that is the ticketing site for issues with python ibm_db.

Search for Monterey and/or "symbol not found" and study the workarounds in the various hits,

At the present time, it appears that MachOs v12.1 and higher does not ship the gcc version and its libraries on which the python ibm_db module depends. There are workarounds for some scenarios.

If you do not find a workaround, you can open a new ticket at that issues page. In this specific case, it appears that stackoverflow is not the correct forum.

Answered By: mao

I found the solution:

  1. create a virtual environment and copy libstdc++.6.dylib into ../venv/lib/python3.10/site-packages/clidriver/lib folder.

  2. export DYLD_LIBRARY_PATH=../venv/lib/python3.10/site-packages/clidriver/lib:$DYLD_LIBRARY_PATH

libstdc++.6.dylib can be downloaded from the web.

Answered By: gd1
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.