Rust-bindgen: fatal error: 'stdlib.h' file not found

Created on 11 Feb 2019  路  6Comments  路  Source: rust-lang/rust-bindgen

Input C/C++ Header

#include "iostream"
#include "string"
#include <ctype.h>
#include <tuple>
#include <vector>

enum State{find=0,content=1,element=2,prop=3};
enum Type{open,close,fail};
class Property{
    public:
    std::string str;
    std::string asstr(){
        return this->str;
    }

};
class Style{

};

class Element{
    private:

    std::string element;




    public:
    Property * prop=nullptr;
    std::vector<Element *> child;
    Element * parent=nullptr;
    std::string content;
    std::string contentHTML;
    bool closed = false;
    Element(std::string elname ,Element * parentEl){
        element = elname;
        parent = parentEl;
        prop = new Property();
        //parentEl->child.push_back(this);
    }
    Element(std::string elname){
        element = elname;
    }
    void setParent(Element * parentEl){
        parent = parentEl;
    }
    std::string getTag(){
        return element;
    }
    std::string getParentTag(){
        if(parent==nullptr)
            return"";
        return parent->getTag();
    }
    void setContent(std::string s){
        content = s;
    }
};

void console_view(Element * root);
void parse(std::string page);

Bindgen Invocation

$ bindgen input.hpp

Actual Results

/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/cstdlib:75:15: fatal error: 'stdlib.h' file not found
/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/cstdlib:75:15: fatal error: 'stdlib.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', libcore/result.rs:1009:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:476
   5: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:390
   6: rust_begin_unwind
             at libstd/panicking.rs:325
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:77
   8: core::result::unwrap_failed
   9: std::panicking::try::do_call
  10: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  11: bindgen::main
  12: std::rt::lang_start::{{closure}}
  13: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  14: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  15: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  16: main
  17: __libc_start_main
  18: _start

Expected Results

Everything is ok

Most helpful comment

Same problem here. I expected bindgen to recognize the .hpp extension and automatically configure libclang to use C++.

The -- -x c++ is super obscure, and it's hard to guess that it's the culprit by infinite permutations of broken system header errors (I was getting different weird errors depending on what clang/llvm version I had on the system).

All 6 comments

Huh, that's strange. Can you confirm it works if you do bindgen input.hpp -- -x c++?

[duckerman@duckerman parser]$ bindgen parser.hpp -o parser.rs -- -x c++ [2019-02-11T15:59:34Z ERROR bindgen::ir::item] Unhandled cursor kind 400: Cursor( kind: UnexposedAttr, loc: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/x86_64-pc-linux-gnu/bits/c++config.h:260:43, usr: None) [2019-02-11T15:59:34Z ERROR bindgen::ir::item] Unhandled cursor kind 400: Cursor( kind: UnexposedAttr, loc: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/x86_64-pc-linux-gnu/bits/c++config.h:264:43, usr: None) ....

Yeah, that's expected, those errors are not fatal

Thanks for help :)

Same problem here. I expected bindgen to recognize the .hpp extension and automatically configure libclang to use C++.

The -- -x c++ is super obscure, and it's hard to guess that it's the culprit by infinite permutations of broken system header errors (I was getting different weird errors depending on what clang/llvm version I had on the system).

Same problem here. I expected bindgen to recognize the .hpp extension and automatically configure libclang to use C++.

The -- -x c++ is super obscure, and it's hard to guess that it's the culprit by infinite permutations of broken system header errors (I was getting different weird errors depending on what clang/llvm version I had on the system).

Or at least in -h somehow show a note about it

I think I can help about documenting it in FAQ part of "bindgen user guid"

Was this page helpful?
0 / 5 - 0 ratings