gpt4 book ai didi

rust - 无法使用 bindgen 设置包含路径

转载 作者:行者123 更新时间:2023-12-03 11:46:26 24 4
gpt4 key购买 nike

我正在尝试使用 bindgen 生成与 Qt6 的绑定(bind)。我关注了this回答并尝试了这个: -

let bindings = bindgen::Builder::default()
.header("exclient.hpp")
.clang_arg("
-I/usr/include/qt6
-I/usr/include/qt6/QtCore
-I/usr/include/qt6/QtGui
-I/usr/include/qt6/QtQml
-I/usr/include/qt6/QtQuick
")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("Unable to generate bindings");
但是当我尝试编译它时,我收到以下错误:-

--- stderr
/home/hilomen/Development/qtrusttest/target/debug/build/exclient3-d982a3579dd42390/out
warning:
-I/usr/include/qt6
-I/usr/include/qt6/QtCore
-I/usr/include/qt6/QtGui
-I/usr/include/qt6/QtQml
-I/usr/include/qt6/QtQuick
: 'linker' input unused [-Wunused-command-line-argument]
exclient.hpp:3:10: fatal error: 'QObject' file not found
warning:
-I/usr/include/qt6
-I/usr/include/qt6/QtCore
-I/usr/include/qt6/QtGui
-I/usr/include/qt6/QtQml
-I/usr/include/qt6/QtQuick
: 'linker' input unused [-Wunused-command-line-argument], err: false
exclient.hpp:3:10: fatal error: 'QObject' file not found, err: true
我可以确认 /usr/include/qt6/QtCore/QObject文件确实存在

最佳答案

愚蠢的我,我应该使用 clang args 而不是 clang arg

let bindings = bindgen::Builder::default()
.header("exclient.hpp")
.clang_args(&[
"-I/usr/include/qt6",
"-I/usr/include/qt6/QtCore",
"-I/usr/include/qt6/QtGui",
])
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("Unable to generate bindings");

关于rust - 无法使用 bindgen 设置包含路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66546971/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com