너를 속였다
너를 속였다

Reputation: 1079

can't set include path with bindgen

I'm trying to genrate binding to Qt6 with bindgen. I have followed this answer and tried 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");

but when I try to compile this, I get following error:-


  --- 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

I can confirm that /usr/include/qt6/QtCore/QObject file does exists

Upvotes: 0

Views: 1512

Answers (1)

너를 속였다
너를 속였다

Reputation: 1079

silly me, I shoul've used clang_args instead of 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");

Upvotes: 2

Related Questions