Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic symbol lookup fails with statically embedded Python on Mac OS X
    primarykey
    data
    text
    <p>I'm building a Mac OS X application that is to embed Python. My application is technically a bundle (i.e. its main executable is MH_BUNDLE); it's a plug-in for another application. I'd like it to embed Python statically, but want to be able to load extensions dynamically.</p> <p>I did the following: I included a whole library (<code>-force_load path/to/libpython2.7.a</code>), also reexported all Python symbols (<code>-exported_symbol_list path/to/list</code>), and added the <code>-u _PyMac_Error</code>, which I got using <a href="http://docs.python.org/extending/embedding.html#linking-requirements" rel="nofollow">this linking advice</a>. The bundle itself loads fine, all internal Python code appears to work, but it fails when it it tries to import a dynamic library (<code>time.so</code>) with the following message:</p> <pre><code>Traceback (most recent call last): ... ImportError: dlopen(/&lt;stripped&gt;/time.so, 2): Symbol not found: _PyExc_OverflowError Referenced from: /&lt;stripped&gt;/time.so Expected in: dynamic lookup </code></pre> <p>This symbol is a part of Python API and it must be in my bundle already. I can check this:</p> <pre><code>nm -g Build/Debug/pyfm | grep _PyExc_OverflowError 00172884 D _PyExc_OverflowError 0019cde0 D _PyExc_OverflowError </code></pre> <p>(It's listed twice because I have two architectures, i386 and ppc). </p> <p>The <code>time.so</code> doesn't reference anything, which, as I understand, is by design:</p> <pre><code>otool -L "/&lt;stripped&gt;/time.so" /&lt;stripped&gt;/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) /&lt;stripped&gt;/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) </code></pre> <p>My problem appears to be similar to <a href="http://bugs.python.org/issue4434" rel="nofollow">this</a>, but it's the other way round: I do link Python statically, while the other poster linked it dynamically (an our platforms are different too). For him static linking solved the problem. </p> <p>Why doesn't it find the symbol?</p> <p><strong>Update.</strong> I suspect it happens because the main app loads its plug-ins (and thus my bundle) with <code>RTLD_LOCAL</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload