2

I am trying to port qmake project to meson build system.
Project is a simple Qt GUI application, with no other dependencies.
Application is cross-platform one, it must compile and run on macOS/Linux/Windows.

Right now i'm stuck on mac.
Debug application binary built by ninja/meson unable to load:

mac:~ user$ Projects/qgit/__build__/qgit
dyld: Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore
  Referenced from: /Users/eraxillan/Projects/qgit/__build__/qgit
  Reason: image not found
Abort trap: 6

Documentation mention two rpath-related parameters:

  • build_rpath

  • install_rpath

I've tried both, specifying path to local Qt installation (export DYLD_FRAMEWORK_PATH=/Users/user/Qt/5.12.3/clang_64/lib), but nothing changes:

mac:test user$ otool -L __build__/test
__build__/test:
    @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.12.0, current version 5.12.3)
    @rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.12.0, current version 5.12.3)
    @rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.12.0, current version 5.12.3)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)

I expected meson changes @rpath to specified, but it don't.
What is my problem, am i doing smth wrong?

P.S. There is a workaround:

export DYLD_FRAMEWORK_PATH=/Users/user/Qt/5.12.3/clang_64/lib
__build__/test
# it now works

P.P.S. meson.build:

project('test', 'cpp', default_options : ['cpp_std=c++11', 'warning_level=3'])

qt5 = import('qt5')
qt5_dep = dependency('qt5', modules : ['Core', 'Gui', 'Widgets'])

incdir = include_directories('src')

prep = qt5.preprocess(
                    moc_headers : test_headers,
                    ui_files : test_forms,
                    qresources : test_resources,
                    include_directories : incdir,
                    dependencies: qt5_dep)

...

q5exe = executable('test',
                    sources : [test_sources, prep],
                    dependencies : [qt5_dep],
                    include_directories : incdir,
                    install : true,
                    build_rpath : '/Users/user/Qt/5.12.3/clang_64/lib',
                    #install_rpath : '/Users/user/Qt/5.12.3/clang_64/lib'
                    )
eraxillan
  • 1,552
  • 1
  • 19
  • 40
  • `build_rpath : 'Users/user/Qt/5.12.3/clang_64/lib'` I think you missed the first `/` .... try `build_rpath : '/Users/user/Qt/5.12.3/clang_64/lib'` – Richard Barber Jun 04 '19 at 13:17
  • Also, I always `macdeployqt` any qt app before testing (regardless the build system). – Richard Barber Jun 04 '19 at 13:19
  • Sorry, that was just a typo - already fixed. My problem is that `build_rpath` actually changes nothing. About `macdeployqt` - i've considered this as overhead, i need only to change `rpath`; it's better to just add `DYLD_FRAMEWORK_PATH ` – eraxillan Jun 04 '19 at 13:26
  • Actually it is better to one-time it with `install_name_tool -add_rpath /Users/user/Qt/5.12.3/clang_64/lib __build__/test` – Richard Barber Jun 04 '19 at 13:28
  • It works, thanks! as `DYLD_FRAMEWORK_PATH`. However, i expect from `meson` to do the same thing. If you have any thoughts, please write 'em as answer – eraxillan Jun 04 '19 at 13:35
  • @eraxillan could you please write full answer? – ManWithBear Dec 11 '19 at 17:58
  • 1
    @ManWithBear Well, AFAIR i just ran `install_name_tool` mentioned above. I will check it again when get some free time – eraxillan Dec 13 '19 at 13:35
  • With https://github.com/mesonbuild/meson/pull/9728 applied to Meson, you can also use `build_rpath : qt5_dep.get_variable(configtool : 'QT_INSTALL_LIBS')`. – bb010g Dec 14 '21 at 22:52

0 Answers0