plugin: export Qt plugin entry symbols from cdylib via --export-dynamic

This commit is contained in:
Damocles 2026-05-03 19:55:10 +02:00
parent dad977d4c5
commit 2a691aa66f
2 changed files with 7 additions and 12 deletions

View file

@ -1,6 +1,13 @@
use cxx_qt_build::{CxxQtBuilder, PluginType, QmlModule};
fn main() {
// Rust cdylib uses a version script that hides everything not declared
// `#[no_mangle] pub extern "C"`. cxx-qt's QQmlEngineExtensionPlugin entry
// points (qt_plugin_instance, qt_plugin_query_metadata_v2) come from
// compiled C++ and would otherwise be stripped to local visibility, so Qt's
// plugin loader finds nothing exported. --export-dynamic re-exposes them.
println!("cargo:rustc-link-arg=-Wl,--export-dynamic");
CxxQtBuilder::new_qml_module(QmlModule::new("NovaStats").plugin_type(PluginType::Dynamic))
.files(["src/system_stats.rs", "src/cpu_service.rs"])
.build();