Skip to content

import error #1510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Feb 1, 2019 · 7 comments
Closed

import error #1510

ghost opened this issue Feb 1, 2019 · 7 comments

Comments

@ghost
Copy link

ghost commented Feb 1, 2019

hello.I am using leveleb to test this project, I have encountered such a problem, I can do it in g++ environment.

--- stdout
cargo:rustc-link-lib=/home/orange/work/rust/material/main/cpprust/libleveldb.a

--- stderr
/usr/include/leveldb/slice.h:21:10: fatal error: 'string' file not found
/usr/include/leveldb/slice.h:21:10: fatal error: 'string' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', src/libcore/result.rs:1009:5
note: Run with RUST_BACKTRACE=1 for a backtrace.

@emilio
Copy link
Contributor

emilio commented Feb 1, 2019

Can you paste example code or a link? I suspect you need to pass -x c++ to the arguments.

@ghost
Copy link
Author

ghost commented Feb 1, 2019

Yes, I added x, I have a question.

For (https://github.com/rust-lang/rust-bindgen/blob/master/bindgen-integration/build.rs)
I compiled Test.cc into a static library in advance, and then changed the following to something that would have an error.

     // use std::fs;
     // let v = vec!["cpp/Test.cc"];
     // let mut iter = v.into_iter();
     // cc::Build::new()
     // .cpp(true)
     // .files(iter)
     // .compile("libtest.a");
   
     Println!("cargo:rustc-link-search=native={}","/home/orange/work/rust/material/main/cpp/cpp");
    
     Let library_test = "test";
     Println!("cargo:rustc-link-lib=static={}", library_test);
I confirm that the path to libtest.a is correct.
thank you very much

@ghost
Copy link
Author

ghost commented Feb 1, 2019

I use rocksdb test:
println!("cargo:rustc-link-search=native={}/dependences",current_dir_name);
println!("cargo:rustc-link-lib=static=rocksdb");
println!("cargo:rustc-link-lib=stdc++");
println!("cargo:rustc-link-lib=pthread");
println!("cargo:rustc-link-lib=snappy");
println!("cargo:rustc-link-lib=rt");
println!("cargo:rustc-link-lib=gflags");
println!("cargo:rustc-link-lib=z");
println!("cargo:rustc-link-lib=bz2");
println!("cargo:rustc-link-lib=lz4");
println!("cargo:rustc-link-lib=zstd");

let bindings = bindgen::Builder::default()
    .header("dependences/wrapper.h")
    .clang_args(&["-x"])
    .generate()
    .expect("Unable to generate bindings");

let out_path = PathBuf::from("src");
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");

wraper.h
#include "rocksdb/db.h"
#include "rocksdb/slice.h"
#include "rocksdb/options.h"

@emilio
Copy link
Contributor

emilio commented Feb 1, 2019

You should be able to use .clang_args(&["-x", "c++"]), does that work?

@ghost
Copy link
Author

ghost commented Feb 2, 2019

I use .clang_args(&["-x","c++","-std=c++14"])

--- stderr
thread 'main' panicked at '"std___shared_count___shared_count<_Lp>" is not a valid Ident', /home/orange/.cargo/registry/src/jiasu.xzqcsaa.nyc.mn-1ecc6299db9ec823/proc-macro2-0.4.27/src/fallback.rs:594:9
note: Run with RUST_BACKTRACE=1 for a backtrace.

@emilio
Copy link
Contributor

emilio commented Feb 2, 2019

That sounds like #1464, see there for workarounds.

@emilio
Copy link
Contributor

emilio commented Feb 23, 2019

I think this should be working now since #1464 is fixed, let me know otherwise.

@emilio emilio closed this as completed Feb 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant