简体   繁体   中英

Compiling rust-bindgen on Ubuntu

Did anybody manage to compile rust-bindgen on Ubuntu 14.04? I don't know, for example, how to statically build and link to libclang.so . I use rust-nightly.

The following only sets up the executable, not the macro.

I assume you have git and rustc setup correctly. bindgen will need a fairly recent rustc to compile.

Clone the repository:

$ git clone https://github.com/crabtw/rust-bindgen
$ cd rust-bindgen

Build the library:

$ rustc lib.rs

Build the wrapping executable, linking with the previously built library:

$ rustc -L . bindgen.rs

Run the executable, in this case on the Xlib headers:

$ ./bindgen -l xlib -o xlib.rs /usr/include/X11/Xlib.h

The executable may segfault if libclang is setup wrong. In that case, preload the correct library and pass the right options to clang:

$ LD_PRELOAD=/usr/lib/libclang.so ./bindgen -I /usr/lib/clang/3.4.2/include -l xlib -o xlib.rs /usr/include/X11/Xlib.h

To install the correct version of clang, you may try to install libclang-dev .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM