osx - Dynamic symbol lookup fails with statically embedded Python on Mac OS X -
i'm building mac os x application embed python. application technically bundle (i.e. main executable mh_bundle); it's plug-in application. i'd embed python statically, want able load extensions dynamically.
i did following: included whole library (-force_load path/to/libpython2.7.a
), reexported python symbols (-exported_symbol_list path/to/list
), , added -u _pymac_error
, got using this linking advice. bundle loads fine, internal python code appears work, fails when it tries import dynamic library (time.so
) following message:
traceback (most recent call last): ... importerror: dlopen(/<stripped>/time.so, 2): symbol not found: _pyexc_overflowerror referenced from: /<stripped>/time.so expected in: dynamic lookup
this symbol part of python api , must in bundle already. can check this:
nm -g build/debug/pyfm | grep _pyexc_overflowerror 00172884 d _pyexc_overflowerror 0019cde0 d _pyexc_overflowerror
(it's listed twice because have 2 architectures, i386 , ppc).
the time.so
doesn't reference anything, which, understand, design:
otool -l "/<stripped>/time.so" /<stripped>/time.so (architecture ppc): /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libsystem.b.dylib (compatibility version 1.0.0, current version 88.3.11) /<stripped>/time.so (architecture i386): /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libsystem.b.dylib (compatibility version 1.0.0, current version 88.3.11)
my problem appears similar this, it's other way round: link python statically, while other poster linked dynamically (an our platforms different too). him static linking solved problem.
why doesn't find symbol?
update. suspect happens because main app loads plug-ins (and bundle) rtld_local
.
the “update” made suggests right: main plug-in bundle loaded locally (rtld_local
), nobody can see symbols there, unless using explicit dlopen
followed dlsym
.
if linux promote bundle global namespace dlopen
ing again rtld_global
flag, under mac os x doesn't work. mac os x nicely packs stuff bundles, made dynamic library , put plug-in bundle directory. library loads automatically rtld_global
, python symbols available.
Comments
Post a Comment