Trouble freezing (with PyInstaller) python source including multiprocessing module in Solaris
<p>I'm trying to freeze and distribute among my Solaris11 machines the following python code which makes use of multiprocessing module:</p>

<pre><code>import multiprocessing

def f(name):
    print 'hello', name

if __name__ == '__main__':
    p = multiprocessing.Process(target=f, args=('fer',))
    p.start()
    p.join()
</code></pre>

<p>However, even if the executable works fine under the compiler machine (Solaris11) ...</p>

<pre><code>[root@zgv-wodbuild01 pyinstaller]# testfer/dist/testfer
hello fer
[root@zgv-wodbuild01 pyinstaller]# echo $?
0
</code></pre>

<p>...complains about multiprocessing library in any other machine (Solaris11):</p>

<pre><code>root@dest01a # ./testfer.r004 
Traceback (most recent call last):
File "testfer.py", line 1, in &lt;module&gt;
File "/root/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
File "multiprocessing/__init__.py", line 84, in &lt;module&gt;
File "/root/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 546, in load_module
ImportError: ld.so.1: testfer.r004: fatal: relocation error: file /tmp/_MEIlBa4uh/_multiprocessing.so: symbol __xnet_sendmsg: referenced symbol not found
Failed to execute script testfer
root@dest01a # echo $?
255
</code></pre>

<p>PyInstaller command has been launched with <code>--onefile</code> flag so every needed library should be included inside final ELF file (multiprocessing too). But I have also tried to include explicitly multiprocessing library by editing <code>hidden-import</code> section in the .spec file.</p>

<p>I have also tried to freeze the source in an older Solaris 10 machine to ensure backwards compatibility. Compiling the PyInstaller bootloaders both with and without special LDFLAGS like <code>-lrt</code>. Using <code>--debug</code> flag. But so far nothing worked nor gave me a clue.</p>

<p>Apparently the binary is properly built for the right architecture and there is no library issues:</p>

<pre><code>root@dest01a # file testfer.r004 
testfer.r004:   ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC1 Extensions Required, dynamically linked, stripped

root@dest01a # crle 
Platform:     32-bit MSB SPARC
Default Library Path (ELF):   /lib:/usr/lib  (system default)
Trusted Directories (ELF):    /lib/secure:/usr/lib/secure  (system default)

root@dest01a # ldd -r testfer.r004 
        libdl.so.1 =&gt;    /lib/libdl.so.1
        libm.so.2 =&gt;     /lib/libm.so.2
        libz.so.1 =&gt;     /lib/libz.so.1
        librt.so.1 =&gt;    /lib/librt.so.1
        libc.so.1 =&gt;     /lib/libc.so.1

root@dest01a # ldd -r /lib/libsocket.so.1 
        libnsl.so.1 =&gt;   /lib/libnsl.so.1
        libc.so.1 =&gt;     /lib/libc.so.1
        libmp.so.2 =&gt;    /lib/libmp.so.2
        libmd.so.1 =&gt;    /lib/libmd.so.1
        libsoftcrypto.so.1 =&gt;    /lib/libsoftcrypto.so.1
        libelf.so.1 =&gt;   /lib/libelf.so.1
        libcryptoutil.so.1 =&gt;    /lib/libcryptoutil.so.1
        libz.so.1 =&gt;     /lib/libz.so.1
        libm.so.2 =&gt;     /lib/libm.so.2
</code></pre>

<p>So I ran out of ideas.
Thanks in advance for any insight.</p>

<p><strong>Update</strong>: Thanks to Andrew Henle comments I've been able to make some progress. I have recompiled the PyInstaller bootloaders again but this time establishing LDFLAGS environment variable to <code>LDFLAGS="-lsocket -lrt"</code>.</p>

<p>Now it's not complaining about <code>__xnet</code> symbols anymore but <code>symbol get_fips_mode</code> instead. As you can see:</p>

<pre><code>root@lnrep01a # ./testfer.r004 
ld.so.1: testfer.r004: fatal: relocation error: file /lib/libsoftcrypto.so.1: symbol get_fips_mode: referenced symbol not found
Killed
</code></pre>

<p>So probably I just need to add some extra flags to compiling process. I will look for them across the internet but if someone knows what is missing, that would be more than welcome.</p>

<p>Turned out it wasn't a gcc bug. After analysing in depth both environments, I realized the <code>/lib/libsoftcrypto.so.1</code> libraries differs a lot. As a matter of fact, the library in the compiler machine contains <code>get_fips_mode</code> symbol...</p>

<pre><code>[root@zgv-wodbuild01 pyinstaller]# nm /lib/libsoftcrypto.so.1  | grep -i get_fips_mode
[3438]  |    623016|       212|FUNC |GLOB |0    |18     |get_fips_mode
</code></pre>

<p>...while the destination machine does not:</p>

<pre><code>root@dest01a # nm /lib/libsoftcrypto.so.1  | grep -i get_fips_mode
[3755]  |         0|         0|FUNC |GLOB |0    |UNDEF  |get_fips_mode
</code></pre>

<p>After trying another compiler machine with similar library version, compiling the pyinstaller bootloaders with <code>-lsocket</code> ldflag was enough:</p>

<pre><code>root@dest01a # ./testferv3
hello fer
root@dest01a # echo $?
0
</code></pre>

python multiprocessing solaris pyinstaller