You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compiled example cannot find Qt on OSX due to an rpath issue.
$ cd libqmlbind-sys
$ cargo build --example hello_world
$ otool -L target/debug/examples/hello_world
target/debug/examples/hello_world:
@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.7.0, current version 5.7.0)
@rpath/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.7.0, current version 5.7.0)
@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.7.0, current version 5.7.0)
@rpath/QtQml.framework/Versions/5/QtQml (compatibility version 5.7.0, current version 5.7.0)
@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.7.0, current version 5.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
$ cat target/debug/build/libqmlbind-sys-8282f5495710b036/output
cargo:rustc-flags=-L libqmlbind/qmlbind
cargo:rustc-link-lib=static=qmlbind
Environnement variable 'QT_DIR' not set!
Defaulting to ${HOME}/Qt/${QT_VER}/${QT_COMP} where:
QT_VER: 5.7
QT_COMP: clang_64
Using Qt directory: "${HOME}/Qt/5.7/clang_64"
Use QT_DIR environment variable to ovewrite.
cargo:rustc-link-search=framework=${HOME}/Qt/5.7/clang_64/lib
cargo:rustc-link-lib=framework=QtCore
cargo:rustc-link-lib=framework=QtNetwork
cargo:rustc-link-lib=framework=QtGui
cargo:rustc-link-lib=framework=QtQml
cargo:rustc-link-lib=framework=QtWidgets
cargo:rustc-flags=-l stdc++
But then:
$ cargo run --verbose --example hello_world
Fresh libc v0.2.13
Fresh libqmlbind-sys v0.0.2 (file:///${HOME}/qmlrsng.git/libqmlbind-sys)
Running `target/debug/examples/hello_world`
dyld: Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore
Referenced from: ${HOME}/qmlrsng.git/libqmlbind-sys/target/debug/examples/hello_world
Reason: image not found
error: Process didn't exit successfully: `target/debug/examples/hello_world` (signal: 5, SIGTRAP: trace/breakpoint trap)
It seems the final binary does not contain LC_RPATH:
Adding -C link-args=-Wl,-rpath,${QT_DIR}/lib to rustc's argument seems to create a working binary, but there does not seem to be a way to set this flag from build.rs...
Compiled example cannot find Qt on OSX due to an rpath issue.
$ cd libqmlbind-sys $ cargo build --example hello_world
But then:
It seems the final binary does not contain
LC_RPATH
:A workaround is to replace the
@rpath
in the binary with absolute paths. For example:install_name_tool -change @rpath/QtCore.framework/Versions/5/QtCore ${QT_DIR}/lib/QtCore.framework/Versions/5/QtCore target/debug/examples/hello_world
The script
libqmlbind-sys/fix_qt_rpath.sh
will perform the required change.The text was updated successfully, but these errors were encountered: