Re: [gtk-osx-users] Need to explicitly export DYLD_FALLBACK_LIBRARY_PATH





On Sep 28, 2019, at 3:20 AM, Timo via gtk-osx-users-list <gtk-osx-users-list gnome org> wrote:

Hello, I followed the build instructions on the wiki and everything's built correctly. However my 
application fails to run with a warning about libpango-1.0.0.dylib not being found and then a traceback. I 
can narrow it down to just doing a `from gi.repository import Gtk`.

    bash-3.2$ python3
    Python 3.6.8 (default, Sep 24 2019, 17:23:22)
    [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from gi.repository import Gtk

    ** (process:45468): WARNING **: 20:30:34.767: Failed to load shared library 'libpango-1.0.0.dylib' 
referenced by the typelib: dlopen(libpango-1.0.0.dylib, 9): image not found
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
      File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/importer.py", line 145, in load_module
        importlib.import_module('gi.repository.' + dep.split("-")[0])
      File "/Users/gtk3/gtk/inst/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
      File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/importer.py", line 145, in load_module
        importlib.import_module('gi.repository.' + dep.split("-")[0])
      File "/Users/gtk3/gtk/inst/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
      File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/importer.py", line 146, in load_module
        dynamic_module = load_overrides(introspection_module)
      File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/overrides/__init__.py", line 118, in 
load_overrides
        override_mod = importlib.import_module(override_package_name)
      File "/Users/gtk3/gtk/inst/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/overrides/Pango.py", line 41, in <module>
        FontDescription = override(FontDescription)
      File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/overrides/__init__.py", line 195, in 
override
        assert g_type != TYPE_NONE
    AssertionError


Explicitly setting DYLD_FALLBACK_LIBRARY_PATH seems to fix the problem:

    bash-3.2$ export DYLD_FALLBACK_LIBRARY_PATH=/Users/gtk3/gtk/inst/lib
    bash-3.2$ python3
    Python 3.6.8 (default, Sep 24 2019, 17:23:22)
    [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from gi.repository import Gtk

    (.:45493): Gtk-WARNING **: 20:33:47.938: Locale not supported by C library.
        Using the fallback 'C' locale.
    __main__:1: PyGIWarning: Gtk was imported without specifying a version first. Use 
gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.


However the same problem happens when I bundle the application. Again, only doing the GTK import in the 
myapp_launcher.py file gives the same error (launcher file taken from gtk-mac-bundler example and Gramps 
for the updated version).

It already has `environ['DYLD_LIBRARY_PATH'] = bundle_lib`, but even adding 
`environ['DYLD_FALLBACK_LIBRARY_PATH'] = bundle_lib` makes no differences. Printing `bundle_lib` points to 
the lib dir inside the bundle and printing `os.path.exists(bundle_lib, 'libpango-1.0.0.dylib')` shows the 
file is actually there. So it's not picking up the Python set env variable.

It's only after I do `export DYLD_FALLBACK_LIBRARY_PATH=/path/to/myapp_bundle.app/Contents/Resources/lib` 
that the bundled app will run, but is of course only feasible to do on my dev machine.

Is it my environment that's tainted somehow? Did the build not correctly pick up paths?

It mostly has to do with meson and rpaths. The latest commit to gtk-mac-bundler, 
https://gitlab.gnome.org/GNOME/gtk-mac-bundler/commit/93edee7e2d0ec8230aaf5acb21452202b10cd678, was supposed 
to fix it, but meson's behavior has been something of a moving target.

What are the installed names (use otool -L and look at the first line) of libpango-1.0.0.dylib in your 
installed prefix and in your bundle?

What version of meson did pip install for you?

Regards,
John Ralls



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]