Question

I am trying to CX_Freeze an application for the Linux Platform. The Windows MSI installer works perfectly but the Linux counter-part doesn't really function the way I want it.

When the package is build it runs perfectly on the original system, but when ported to a different system (although same architecture) it generates a segfault. First thing I did was check the librarys and there are some huge version differences with libc, pthread and libdl. So I decided to include these in the build, like so:

if windows_build:
    build_exe_options['packages'].append("win32net")
    build_exe_options['packages'].append("win32security")
    build_exe_options['packages'].append("win32con")
    pywintypes_dll = 'pywintypes{0}{1}.dll'.format(*sys.version_info[0:2])      # e.g. pywintypes27.dll
    build_exe_options['include_files'].append((os.path.join(GetSystemDirectory(), pywintypes_dll), pywintypes_dll))
else:
    build_exe_options['packages'].append("subprocess")
    build_exe_options['packages'].append("encodings")
    arch_lib_path = ("/lib/%s-linux-gnu" % os.uname()[4])
    shared_objects = ["libc.so.6", "libpthread.so.0", "libz.so.1", "libdl.so.2", "libutil.so.1", "libm.so.6", "libgcc_s.so.1", "ld-linux-x86-64.so.2"]
    lib_paths = ["/lib", arch_lib_path, "/lib64"]
    for so in shared_objects:
        for lib in lib_paths:
            lib_path = "%s/%s" % (lib, so)
            if os.path.isfile(lib_path):
                build_exe_options['include_files'].append((lib_path, so))
                break

After checking the original cx_frozen bin it seems the dynamic libraries play there part and intercept the calls perfectly. Although now I am at the part where pthread segfaults due to the fact that he tries the systems libc instead of mine (checked with ldd and gdb).

My question is quite simple, this method I am trying is horrible as it doesn't do the recursive depency resolving. Therefore my question would be "what is the better way of doing this? or should I write recursive depency solving within my installer?"

And in order to beat the Solution: "Use native Python instead", we got some hardware appliances (think 2~4U) with Linux (and Bash access) where we want to run this aswell. porting entire python (with its dynamic links etcetc) seemd like way to much work when we can cx_freeze it and ship the librarys with.

Was it helpful?

Solution

I don't know about your other problems, but shipping libc.so.6 to another system the way you do it can not possibly work, as explained here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top