rust-lang / nomicon

The Dark Arts of Advanced and Unsafe Rust Programming
https://doc.rust-lang.org/nomicon/
Apache License 2.0
1.74k stars 256 forks source link

Add build script part to FFI chapter for more clear and smooth learn … #440

Open RoggeOhta opened 5 months ago

RoggeOhta commented 5 months ago

Fix #345 #122 Make FFI chapter snappy example workable.

jamischarles commented 4 months ago

@RoggeOhta Thank you thank you thank you. I've been banging my head wondering how on earth to reference snappy.

jamischarles commented 4 months ago

FYI: on macOS I didn't need println!("cargo:rustc-link-lib=dylib=stdc++"); this line in the build script. In fact it caused an error note: ld: library 'stdc++' not found

jamischarles commented 4 months ago

My working build file:

fn main() {
    // println!("cargo:rustc-link-lib=dylib=stdc++");
    println!("cargo:rustc-link-search=/Users/jac/dev/snappy/build");
}

Didn't realize I needed to ref the build folder