记录一次难搞的编译错误-- qml-rust 项目编译无法找到QtCore库的问题

记录一次难搞的编译错误-- qml-rust 项目编译时无法找到QtCore库的问题

  • 背景
  • 开始处理问题
    • 1 看日志找关键点
    • 2 写最简单测试用例
    • 3 写最简单CMake编译的Qt
    • 4 发现问题
    • 5 开始处理错误
    • 过程 1
    • 过程2
    • 过程3
  • 反思
  • 开始找资料,解决自己的困惑。
  • 第二次开始解决问题
  • 第三次解决问题
  • 总结

背景

平台:Mac
项目管理方式:CMake cargo
项目github:CXX-QT
这个项目主要是一个Qt /Qml 和 rust互操作的一个实现。
在编译项目时,链接阶段报错:

QtCore not found.

日志文件:

[main] Building folder: cxx-qt
[build] Starting build
[proc] Executing command: /opt/homebrew/bin/cmake --build /Users/allen/Projects/RustProjects/cxx-qt/build --config Debug --target _cargo-build_qml-features –
[build] [1/2 0% :: 0.002] cd /Users/allen/Projects/RustProjects/cxx-qt/examples/qml_features/rust && /Applications/CMake.app/Contents/bin/cmake -E env CXXQT_EXPORT_DIR=/Users/allen/Projects/RustProjects/cxx-qt/build/examples/qml_features/cxxqt DYLD_FRAMEWORK_PATH=/opt/homebrew/Cellar/qt@5/5.15.12_1/lib QMAKE=/opt/homebrew/Cellar/qt@5/5.15.12_1/bin/qmake CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=/usr/bin/clang CC_aarch64-apple-darwin=/usr/bin/clang CXX_aarch64-apple-darwin=/usr/bin/clang++ SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk CORROSION_BUILD_DIR=/Users/allen/Projects/RustProjects/cxx-qt/build/examples/qml_features CARGO_BUILD_RUSTC=/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc /Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo rustc --lib --target=aarch64-apple-darwin --package qml-features --manifest-path /Users/allen/Projects/RustProjects/cxx-qt/examples/qml_features/rust/Cargo.toml --target-dir /Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build – -Cdefault-linker-libraries=yes
[build] Compiling cxx-qt-lib v0.6.0 (/Users/allen/Projects/RustProjects/cxx-qt/crates/cxx-qt-lib)
[build] Compiling qml-features v0.1.0 (/Users/allen/Projects/RustProjects/cxx-qt/examples/qml_features/rust)
[build] error: linking with /usr/bin/clang failed: exit status: 1
[build] |
[build] = note: env -u IPHONEOS_DEPLOYMENT_TARGET -u TVOS_DEPLOYMENT_TARGET LC_ALL=“C” PATH=“/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/allen/.cargo/bin:/Users/allen/Library/Application Support/JetBrains/Toolbox/scripts:/Users/allen/Library/Python/3.9/bin” VSLANG=“1033” ZERO_AR_DATE=“1” “/usr/bin/clang” “-arch” “arm64” “/var/folders/hw/lc023pr55psdqktjg68xvnkw0000gn/T/rustc7cGQY5/symbols.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.10fl17pzfgknotu.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.119okv1xmy7z81f6.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.137xat5v19szbkn0.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.15oph1vhrzhh5e5j.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.19opgb164thgeyxk.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.1vlp0hyqz47obvqu.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.1yhg74qrm5jbn57.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.26tes9igtz8fy7rn.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.2mfoke3mrp14psgs.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.2xsado67lvou67qs.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.2zb7b71tju74uh5j.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.37xis5uwom24c582.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.3qh0u66rpovuphck.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.4186phjz8kddzw0h.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.42i2ewundsav9ojs.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.45d9edr6wy3brpeh.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.4aqs871owq9ftsf1.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.4zbmzfjwshprgoiz.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.4zm0s84o8zrdyxpo.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.55605lsdx0j8mjk3.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.55mmkitcjyl348i7.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.5663x8hp4g2zm7jf.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.59c517g8ydpmusil.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.xhcy1h0fk613fhe.rcgu.o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7.4qr33kompxeqtcjw.rcgu.o” “-L” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/deps” “-L” “/opt/homebrew/Cellar/qt@5/5.15.12_1/lib” “-L” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-cd4fe937a4be2c39/out” “-L” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-201f66f53e1e6176/out” “-L” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/link-cplusplus-71603c78c2dde3e1/out” “-L” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libcxx_qt_lib_headers-d9912cca892c1c19.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libcxx_qt_build-6ab1336d900c684d.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libversion_check-9f51aa7577df62b5.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libcxx_qt-d2c539d1a4753f86.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libstatic_assertions-21ebe0eb3cea606d.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libcxx-0dae514a5f69b4e8.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/liblink_cplusplus-29d675dabc421268.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libqt_build_utils-906dd61ff2dbfcbc.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libversions-8466793749c2eea6.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libnom-718756c2487eced8.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libmemchr-e6b5ebc697c65687.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libitertools-e621136652a36976.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libeither-f70f4bfdd6077160.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libcc-4f7e5addbf99ef3e.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libjobserver-dd4b614b2cf16aea.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/liblibc-dd2450870a8e46be.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libcxx_gen-5eee1925fa27fac5.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libcxx_qt_gen-8d441a361f4b6960.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libclang_format-089b44882994e1ab.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libthiserror-dd35499ccfe2017d.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libconvert_case-35c30cdcabc87c2a.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libunicode_segmentation-7d3ed2ca008d237f.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libsyn-ac3b92559e3bce53.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libquote-f7d359d29bfc9b4a.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libcodespan_reporting-16803727eb35ee92.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libunicode_width-16a1984432142341.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libtermcolor-3d23a97142594491.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libproc_macro2-950e5ceb51725b27.rlib” “/Users/allen/Projects/RustProjects/cxx-qt/build/cargo/build/debug/deps/libunicode_ident-2260bb06186abcf3.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libproc_macro-c7150b0669ad7a0f.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd-4f192af08beaa759.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-401344856f0fc3c5.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libobject-9e012890a70780c2.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libmemchr-60338fe528589910.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-a2e883cf5bcf6347.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libgimli-df8440ef641907f8.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-fa2288bf7728f91c.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-f39c850853dd7dfe.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-c5b1930e10569ddd.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-96bad2fc8f58f610.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libminiz_oxide-06eec439eca0e252.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libadler-023007819562a373.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libunwind-7254491d238c3b3e.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-9f474e4309122405.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liblibc-0bfd536a501ea558.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-d56621fef414e9f8.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-60d6843fd08e9533.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-62a9b4d83244cb2b.rlib” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-4010f8e9d1f7f9aa.rlib” “-framework” “QtCore” “-framework” “DiskArbitration” “-framework” “IOKit” “-lc++” “-liconv” “-lSystem” “-lc” “-lm” “-L” “/Users/allen/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib” “-o” “/Users/allen/Projects/RustProjects/cxx-qt/build/./cargo/build/debug/build/cxx-qt-lib-6020208f1a041cc7/build_script_build-6020208f1a041cc7” “-Wl,-dead_strip” “-nodefaultlibs”
[build] = note: ld: framework ‘QtCore’ not found
[build] clang: error: linker command failed with exit code 1 (use -v to see invocation)
[build]
[build]
[build] error: linking with /usr/bin/clang failed: exit status: 1
[build] |

开始处理问题

1 看日志找关键点

首先查看日志数据,发现

“-L” “/opt/homebrew/Cellar/qt@5/5.15.12_1/lib”

说明CMake已经找到了qt的lib目录,查看对应目录的内容,

tree -L 1 /opt/homebrew/Cellar/qt@5/5.15.12_1/lib | grep QtCore
output:
QtCore.framework

发现有对应的库,但是库是framework结构,而不是.a 或.lib等结构。

再看编译命令:

“-framework” “QtCore” “-framework” “DiskArbitration” “-framework” “IOKit”

发现已经添加了-framework标记来链接这个库,按理说应该可以找到这个库。

2 写最简单测试用例

写一个最简单的my_demo.cpp

#include <iostream>
#include <QtCore/qobject.h>int main(int argc,char** argv)
{QObject* obj = new QObject();obj->setObjectName("obj");std::cout<<"Hello world !"<<std::endl;return 0;
}

my_demo.cpp

从上面的clang命令中提取关键编译信息,
执行如下命令进行编译这个项目:

/usr/bin/clang -arch arm64 -o my_demo my_demo.cpp
-L/opt/homebrew/Cellar/qt@5/5.15.12_1/lib
-framework QtCore -framework DiskArbitration -framework IOKit
-lc++

output:

// fatal error: ‘QtCore/qobject.h’ file not found

发现确实有这个问题,但是明明指定了链接的目录-L 也指定了链接的库 -framework
那么为什么不行呢?

3 写最简单CMake编译的Qt

通过QtCreator创建一个CMkae管理的Qt项目,然后进行编译,查看build目录下的compile_commands.json
查看具体执行的编译命令。

4 发现问题

最后发现,可以编译通过的Qt项目,

-iframework /Users/allen/Soft/Qt/6.5.3/macos/lib

他们指定目录时用的是-iframework 参数,而不是-L。
查看clang手册,

-iframework
Add directory to SYSTEM framework search path

发现-iframework和-L确实不一样,-iframework是mac平台下专门为了查找framework指定目录的一个参数,需要用-iframework指定framework的所在目录,然后使用-framework才能链接到这个库。

继续翻,发现

-F
Add directory to framework include search path

就是说俩有点区别,但都是用来指定framework目录的,用my_demo 发现都可以编译通过。

5 开始处理错误

已经找到了错误问题,开始着手处理问题。
回头查看日志,发现报错是在

[build] Compiling qml-features v0.1.0 (/Users/allen/Projects/RustProjects/cxx-qt/examples/qml_features/rust)

进入对应的CMakeLists.txt文件,找一下对应的地方:

set(CRATE qml-features)
corrosion_import_crate(MANIFEST_PATH rust/Cargo.toml CRATES ${CRATE})
set(CXXQT_EXPORT_DIR "${CMAKE_CURRENT_BINARY_DIR}/cxxqt")
corrosion_set_env_vars(${CRATE}"CXXQT_EXPORT_DIR=${CXXQT_EXPORT_DIR}""QMAKE=${QMAKE}"$<$<BOOL:${CMAKE_RUSTC_WRAPPER}>:RUSTC_WRAPPER=${CMAKE_RUSTC_WRAPPER}>
)

发现这里通过使用CMake的函数corrosion_import_crate 将rust的Cargo.toml导入进去,应该是这里处理的rust项目。

进入corrosion库目录,查看对应的函数、文档,发现了很多接口,如下是我试验的一些过程:

过程 1

CMakeLists.txt的改动
结果是不生效。
对于实际执行的clang命令没有任何改变!

过程2

rustflags = ["-C", "link-arg=-F/opt/homebrew/Cellar/qt@5/5.15.12_1/lib"]

在根目录增加.cargo/config文件,添加上述内容。

结果是不生效。
对于实际执行的clang命令没有任何改变!

过程3

qml-feature/rust/build.rs
在这里qml-feature/rust/build.rs
增加rust的编译内容。
结果是不生效。
对于实际执行的clang命令没有任何改变!

反思

当天搞到了晚上一点多,虽然找到了问题,但是却怎么弄都不行,睡了一觉第二天回想一下这个问题,发现自己有这么几点没搞明白:
1 为什么cmake不会改变clang的执行命令?
2 cmake是如何调用了rust的编译器,又是如何调用到最后的clang命令的?

开始找资料,解决自己的困惑。

通过查看corrosion这个库的函数,发现CMake最后通过run_custom_command的方式,调用了cargo , 然后cargo调用rustc 然后调用了clang。我去,给我整郁闷了。

第二次开始解决问题

打开对应的corrosion库,在里面的多个地方增加对应的函数,尝试编译。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
发现都没有效果😭

第三次解决问题

为什么就是不能用呢?
去cargo 官方搜索文档,
google

cargo link framework

发现buildscript中有这么一个参数:

cargo:rustc-link-search=[KIND=]PATH
The rustc-link-search instruction tells Cargo to pass the -L flag to the compiler to add a directory to the library search path.

The optional KIND may be one of dependency, crate, native, framework,
or all. See the rustc book for more detail.

These paths are also added to the dynamic library search path
environment variable if they are within the OUT_DIR. Depending on this
behavior is discouraged since this makes it difficult to use the
resulting binary. In general, it is best to avoid creating dynamic
libraries in a build script (using existing system libraries is fine).

Ok,找到这个参数了,剩下的就是怎么给他放进去了。

其中的过程不赘述了,
在crates/cxx-qt的build.rs中
加入

println!("cargo:rustc-link-search=framework=/opt/homebrew/Cellar/qt@5/5.15.12_1/lib");

最后编译即可正常。但是这个不是最好的办法,最好应该是让他自动解决这个符号。
后续再说吧,搞了四天才搞定这个麻烦问题。

总结

没事少碰还不是很完善的东西。
我指的是QML和rust互操作。Rust还是很好用的。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/542276.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

升入理解计算机系统学习笔记

磁盘存储 磁盘是广为应用的保存大量数据的存储设备&#xff0c;存储数据的数量级可以达到几百到几千千兆字节&#xff0c;而基于RAM的存储器只能有几百或几千兆字节。不过&#xff0c;从磁盘上读信息的时间为毫秒级&#xff0c;比从DRAM读慢了10万倍&#xff0c;比从SRAM读慢了…

Discourse 分类图片

我们可以在 Discourse 上为分类添加图片。 进入分类编辑界面&#xff0c;然后选择 Image 标签。 在 Images 标签下&#xff0c;上传分类需要的图片。 图片大小 图片的大小是 Discourse 进行控制的&#xff0c;高度为 150 PX 像素。 如果上传的图片大于 150 px 的高度像素&…

智慧城市:提升城市治理能力的关键

目录 一、智慧城市的概念及特点 二、智慧城市在提升城市治理能力中的应用实践 1、智慧交通&#xff1a;提高交通治理效率 2、智慧政务&#xff1a;提升政府服务水平 3、智慧环保&#xff1a;加强环境监测与治理 4、智慧安防&#xff1a;提高城市安全水平 三、智慧城市在…

STM32F103 CubeMX 使用USB生成鼠标设备

STM32F103 CubeMX 使用USB生成鼠标设备 1 配置cubeMX1.1配置外部晶振&#xff0c;配置debug口1.2 配置USB1.3 配置芯片的时钟1.4 生成工程 2. 编写代码2.1 添加申明2.2 main函数代码 1 配置cubeMX 1.1配置外部晶振&#xff0c;配置debug口 1.2 配置USB 1.3 配置芯片的时钟 需…

Vulnhub - Jarbas

希望和各位大佬一起学习&#xff0c;如果文章内容有错请多多指正&#xff0c;谢谢&#xff01; 个人博客链接&#xff1a;CH4SER的个人BLOG – Welcome To Ch4sers Blog Jarbas 靶机下载地址&#xff1a;https://www.vulnhub.com/entry/jarbas-1,232/ 0x01 信息收集 Nmap…

openssl3.2 - note - Decoders and Encoders with OpenSSL

文章目录 openssl3.2 - note - Decoders and Encoders with OpenSSL概述笔记编码器/解码器的调用链OSSL_STORE 编码器/解码器的名称和属性OSSL_FUNC_decoder_freectx_fnOSSL_FUNC_encoder_encode_fn官方文档END openssl3.2 - note - Decoders and Encoders with OpenSSL 概述 …

从0开始启动一个Django的docker服务

本文是从0开始启动一个Django的docker服务&#xff0c;包括构建镜像,uwsgi启动服务 在服务器上安装ssh&#xff0c;git&#xff0c;生成公钥并复制到服务器上 # 安装ssh yum install openssh-clients # 生成sshkey ssh-keygen # 查看公钥 cat /root/.ssh/id_rsa.pubclone一下…

腾讯地图的(地图选点|输入模糊匹配)

1.支持用户输入框输入进行模糊匹配获取详细地址以及经纬度2.支持用户模糊匹配后点击选点获取详细地址以及经纬度 1.支持用户输入框输入进行模糊匹配获取详细地址以及经纬度2.支持用户模糊匹配后点击选点获取详细地址以及经纬度 <template><div class"tencentMap-…

【类和对象】类的作用域 | 类的实例化 | 类对象模型 | this指针

目录 5.类的作用域 6.类的实例化 6.1成员的声明和定义 6.2实例化出的对象大小 7.类对象模型❗❗ 7.1如何计算类对象的大小 7.2类对象的存储方式猜测 7.3结构体内存对齐规则 7.3.1内存对齐 7.3.2大小端 8.this指针 8.1this指针的引出 8.2this指针的特性 C和C实…

【网络安全】 MSF提权

本文章仅用于信息安全学习&#xff0c;请遵守相关法律法规&#xff0c;严禁用于非法途径。若读者因此作出任何危害网络安全的行为&#xff0c;后果自负&#xff0c;与作者无关。 环境准备&#xff1a; 名称系统位数IP攻击机Kali Linux6410.3.0.231客户端Windows 76410.3.0.234…

CentOS 7 socat命令端口转发 —— 筑梦之路

命令简介 socat是一个功能强大的命令行工具&#xff0c;也可以看作是netcat的加强版&#xff0c;它可以在两个端口之间建立虚拟通道&#xff0c;实现数据的传输。适用于网络调试、端口转发、安全测试等多种场景&#xff0c;是一个适合网络管理员和开发者的工具 yum在线安装 yu…

搭建GItlab实现自动化部署Springboot项目(超详细)

提示&#xff1a;本例程中使用Docker搭建GItlab&#xff0c;Gitlab runner 通过编写CICD文件实现Springboot项目自动部署。 1、拉取GitLab镜像 命令&#xff1a; docker pull gitlab/gitlab-ce2、部署Gitlab&#xff1a; 我们通过docker搭建的gitlab部署项目的时候会出现一个…