rust-bindgen: Document providing include paths and FAQ for missing system headers

Sometimes there is a cryptic fatal error: 'stddef.h' file not found, presumabely when libclang is incorrectly configured:

https://github.com/servo/gecko-media/issues/71 https://github.com/bsteinb/rsmpi/issues/1 https://github.com/rust-lang-nursery/rust-bindgen/issues/242 https://github.com/ajtulloch/caffe.rs/issues/1

In the past, this issue was fixed by making sure to install the clang package or by finding the missing pathes and adding them to the includes.

I was wondering whether bindgen could work around this issue? (The second solution above can be automated.) Alternatively, it could be documented how to fix it.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 3
  • Comments: 17 (5 by maintainers)

Most upvoted comments

Although it may not be rust-bindgen’s problem, but it hurts user experiences of rust-bindgen badly. Hope to find a way to fix it permanently.

I solved this after RTF(Clang)M. The flag for finding macOS frameworks is -F:

In your build.rs add sth. like:

.clang_arg("-F/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/")

Each problem is generally different depending on the setup. Could you file a separate issue pointing out which libclang are you using, and the first few lines of running bindgen with RUST_LOG=debug?