I’m loading a not-owned-by-me library with Python’s ctypes
module as ctypes.CDLL("mylib.so")
which produces an error undefined symbol: g_main_context_push_thread_default
because mylib.so
was overlinking a lot of unneeded / unused stuff like glib
.
In this particular case, I can work around this problem successfully by LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 python ...
-ing glib
, but I’m curious in two generic related questions touching on how ctypes
works:
-
Is it possible to ask
ctypes
/dlopen
to ignore undefined symbols, given that I know that these undefined symbols are not used on the code path I’m interested in (or otherwise I would be okay if it crashed in a hard way)? -
Is it possible to ask
ctypes
to load several libraries at once or emulateLD_PRELOAD
-ing? I tried to doctypes.CDLL("/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0")
before loadingctypes.CDLL("mylib.so")
, but it did not help.
Thanks!