Qt problem with LD_LIBRARY_PATH

24 views
Skip to first unread message

Miguel Rasero

unread,
Jul 17, 2020, 7:38:24 AM7/17/20
to PyInstaller
Hello everyone,

I am using Pyinstaller to freeze a PyQt4 Python3 application, using a onedir spec file.

I did the freeze in ubuntu 12.04, when trying to run it in Ubuntu 16.04 I get this error:

ImportError: /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0: undefined symbol: g_variant_dict_ref

I have been debugging the problem using strace, this library is detected and included by Pyinstaller but many libraries are being loaded directly from system library paths instead of being loaded from the frozen directory.

I did check os.environ from inside the frozen program and it is correct, many libraries are loaded from the correct directory indeed, so I used LD_DEBUG=all to get all dynamic library loading debug information.

For most libraries it is correct, for ex:

    10217:     file=libz.so.1 [0];  needed by ./manager [0]
     10217:     find library=libz.so.1 [0]; searching
     10217:      search path=/vagrant/bin/manager               (LD_LIBRARY_PATH)
     10217:       trying file=/vagrant/bin/manager/libz.so.1
     10217:
     10217:     file=libz.so.1 [0];  generating link map
     10217:       dynamic: 0x00007fa77dfefdf0  base: 0x00007fa77ddda000   size: 0x0000000000216230
     10217:         entry: 0x00007fa77dddc050  phdr: 0x00007fa77ddda040  phnum:                  7

But it seems that when the dynamic library it's loaded as a dependency from any of the Qt libraries the system tries to load from system libraries before trying to use LD_LIBRARY_PATH, for ex:

   10217:     file=libgobject-2.0.so.0 [0];  needed by /vagrant/bin/manager/libQtGui.so.4 [0]
     10217:     find library=libgobject-2.0.so.0 [0]; searching
     10217:      search path=           (RPATH from file /vagrant/bin/manager/PyQt4/QtGui.so)
     10217:      search path=/usr/lib/x86_64-linux-gnu          (system search path)
     10217:       trying file=/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
     10217:
     10217:     file=libgobject-2.0.so.0 [0];  generating link map
     10217:       dynamic: 0x00007fa7750acb80  base: 0x00007fa774e5b000   size: 0x0000000000252ee8
     10217:         entry: 0x00007fa774e65f00  phdr: 0x00007fa774e5b040  phnum:                  7

If I delete the file /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0, you can see the difference:

     10222:     file=libgobject-2.0.so.0 [0];  needed by /vagrant/bin/manager/libQtGui.so.4 [0]
     10222:     find library=libgobject-2.0.so.0 [0]; searching
     10222:      search path=           (RPATH from file /vagrant/bin/manager/PyQt4/QtGui.so)
     10222:      search path=/usr/lib/x86_64-linux-gnu          (system search path)
     10222:       trying file=/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
     10222:      search path=/vagrant/bin/manager               (LD_LIBRARY_PATH)
     10222:       trying file=/vagrant/bin/manager/libgobject-2.0.so.0
     10222:
     10222:     file=libgobject-2.0.so.0 [0];  generating link map
     10222:       dynamic: 0x00007f15f4cecaa0  base: 0x00007f15f4a9f000   size: 0x000000000024ef40
     10222:         entry: 0x00007f15f4aaa0b0  phdr: 0x00007f15f4a9f040  phnum:                  7

So if the dynamic system library is not compatible with the frozen one I have problems running the program, that's the case for libgobject for example.

I am a bit lost here, does some know how to handle this?

Thanks!
Miguel



Miguel Rasero

unread,
Jul 20, 2020, 6:11:02 AM7/20/20
to PyInstaller
I compiled Qt from source in the Docker image that freezes the application and now it works launching it in Xenial.

No sure why though, it seems that now the "system search path" that LD tries to use before doing the fallback to LD_LIBRARY_PATH has changed from /usr/lib/x86_64-linux-gnu to /usr/lib, there is no libgobject-2.0.so.0 in the /usr/bin directory so it loads the frozen one and launches the application correctly.

Thanks!
Reply all
Reply to author
Forward
0 new messages