Skip to content

Make it easy to create Rust binaries with rpath set to Qt #566

Open
@tronical

Description

@tronical

This originated from #565

Originally posted by jamesblacklock October 12, 2021
I'm getting the following error when I do a cargo run (seems to be just the run; build works fine):

dyld: Library not loaded: @rpath/QtCore.framework/Versions/A/QtCore
  Referenced from: /Users/<snip>/target/debug/budget
  Reason: image not found

Has anyone seen this error or have any familiarity with getting the sixtyfps qt backend working on macos?

When creating a rust binary with cargo and sixtyfps found Qt available for use, we may want to code the rpath to the Qt library/frameworks on Linux and macOS.

The path is initially determined in qttypes's build.rs and printed via

println!("cargo:rustc-cdylib-link-arg=-Wl,-rpath,{}", &qt_library_path);

Unfortunately this has two problems:

  1. It only "works" when creating a cdylib, so for example the C++ API of SixtyFPS, but not when creating a Rust binary.
  2. The option will cease working in a transitive way as per Tracking issue for rustc-cdylib-link-arg transitive warning rust-lang/cargo#9562

However that cargo issue also suggests a solution that we could implement, which is two fold:

  1. We need rustc-link-arg to show up in a stable release of rust/cargo.
  2. Inside SixtyFPS we need a reliable way to get hold of the correct rpath and then offer API that applications can call from their build.rs that will emit the correct rustc-link-arg=-Wl,rpath,... text to stdout. This could be done automatically by sixtyfps_build::compile() but perhaps there's also a way to offering either a function for build.rs for apps using the macro or the macro could somehow emit #[link_arg(...)].

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:backend-qtThe Qt backend - including the qt style (mO,bS)a:platform-linuxissue specific to Linux, X11 or wayland (mO,bT)a:platform-macosIssues specific to macOS (mS,bF)packagingPackaging and ease of downloading/obtaining Slintpriority:lowLowest priority. The issue is kept open for tracking purpose, but noone is actively working on this

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions