Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tronical opened this issue Oct 12, 2021 Discussed in #565 · 1 comment
Open

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

tronical opened this issue Oct 12, 2021 Discussed in #565 · 1 comment
Labels
a:backend-qt The Qt backend - including the qt style (mO,bS) a:platform-linux issue specific to Linux, X11 or wayland (mO,bT) a:platform-macos Issues specific to macOS (mS,bF) bug Something isn't working packaging Packaging and ease of downloading/obtaining Slint priority:low Lowest priority. The issue is kept open for tracking purpose, but noone is actively working on this

Comments

@tronical
Copy link
Member

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(...)].
@tronical tronical added bug Something isn't working a:platform-linux issue specific to Linux, X11 or wayland (mO,bT) a:platform-macos Issues specific to macOS (mS,bF) labels Oct 12, 2021
@ogoffart
Copy link
Member

In the short term, we should document that. At least in https://github.com/sixtyfpsui/sixtyfps/blob/master/docs/install_qt.md

We could make the sixtyfps-backend-qt to also write a rpath somewhere in a file (like we do for SIXTYFPS_DEFAULT_STYLE.txt) and get sixtyfps-build to read it. But that wouldn't work when using the macro.

tronical added a commit that referenced this issue Jan 4, 2022
For C++ apps we apply rpath to the cdylib implicitly via qttypes, but
link flags for rust binaries are not transitively propagated but require
explicit opt-in by the top-level crate. However we want that
convenience, to avoid Rust apps having to deal with Qt backend specific
code in their build.rs. Therefore we use the _DEP mechanism to get the
qt library path from the qttypes crate and write it into a generic file
in the qt backend's build.rs, which is then picked up by sixtyfps-build.

We'll use the same mechanism to propagate link flags for the MCU build
(such as the linker script).

cc #566
tronical added a commit that referenced this issue Jan 5, 2022
For C++ apps we apply rpath to the cdylib implicitly via qttypes, but
link flags for rust binaries are not transitively propagated but require
explicit opt-in by the top-level crate. However we want that
convenience, to avoid Rust apps having to deal with Qt backend specific
code in their build.rs. Therefore we use the _DEP mechanism to get the
qt library path from the qttypes crate, forward it to the default
backend crate and write it into a generic file in the qt backend's
build.rs, which is then picked up by sixtyfps-build.

In the future, we'll use the same mechanism to propagate link flags for
the MCU build (such as the linker script).

cc #566
tronical added a commit that referenced this issue Jan 5, 2022
For C++ apps we apply rpath to the cdylib implicitly via qttypes, but
link flags for rust binaries are not transitively propagated but require
explicit opt-in by the top-level crate. However we want that
convenience, to avoid Rust apps having to deal with Qt backend specific
code in their build.rs. Therefore we use the _DEP mechanism to get the
qt library path from the qttypes crate, forward it to the default
backend crate and write it into a generic file in the qt backend's
build.rs, which is then picked up by sixtyfps-build.

In the future, we'll use the same mechanism to propagate link flags for
the MCU build (such as the linker script).

cc #566
tronical added a commit that referenced this issue Jan 5, 2022
For C++ apps we apply rpath to the cdylib implicitly via qttypes, but
link flags for rust binaries are not transitively propagated but require
explicit opt-in by the top-level crate. However we want that
convenience, to avoid Rust apps having to deal with Qt backend specific
code in their build.rs. Therefore we use the _DEP mechanism to get the
qt library path from the qttypes crate, forward it to the default
backend crate and write it into a generic file in the qt backend's
build.rs, which is then picked up by sixtyfps-build.

In the future, we'll use the same mechanism to propagate link flags and
extend the linker serach path for the MCU build (such as the linker
script).

cc #566
@ogoffart ogoffart added a:backend-qt The Qt backend - including the qt style (mO,bS) packaging Packaging and ease of downloading/obtaining Slint labels Oct 26, 2022
@ogoffart ogoffart added the priority:low Lowest priority. The issue is kept open for tracking purpose, but noone is actively working on this label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:backend-qt The Qt backend - including the qt style (mO,bS) a:platform-linux issue specific to Linux, X11 or wayland (mO,bT) a:platform-macos Issues specific to macOS (mS,bF) bug Something isn't working packaging Packaging and ease of downloading/obtaining Slint priority:low Lowest priority. The issue is kept open for tracking purpose, but noone is actively working on this
Projects
None yet
Development

No branches or pull requests

2 participants