Cargo test could not link to libv8

This is my build script. cargo build build and generates the bindings.

extern crate bindgen;

use std::env;
use std::path::PathBuf;

fn main() {
    let bindings = bindgen::Builder::default()
        .expect("Could not generate bindings");

    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
        .expect("Could not write bindings");

But when I cargo test, it gives the following error:
error: linking with cc failed: exit code: 1
note: /usr/bin/ld: cannot find -llibv8


This should be v8 instead of libv8. (The linker will automatically translate the library name v8 to a filename like

1 Like

Awesome. Thanks. :smile:
I have a question. Previously, it worked for build but not for test. What different was happening in that case?

Intermediate libraries don't actually link to other libraries - that's deferred until a final executable, like the test harness, is built.