So I've been trying to mess around with Leaf lately, and as someone who's never written a line of C or C++ in their life I was having trouble getting the examples to build. Even though it might be obvious to everyone else, I thought I'd share my findings.
My issue was that the CUDA binaries weren't in any of the link-search directories, so the build failed with:
/usr/bin/ld: cannot find -lcudnn
/usr/bin/ld: cannot find -lOpenCL
/usr/bin/ld: cannot find -lOpenCL
/usr/bin/ld: cannot find -lcublas
/usr/bin/ld: cannot find -lcublas
It turns out it's actually really easy to add link flags to rustc using a cargo build script.
My build.rs just contains the following:
fn main() {
println!("cargo:rustc-link-search=native=/usr/local/cuda/lib64")
}
Dodgy but it works ![]()
I also had some help from this little guide for getting CUDA link path stuff set up in Ubuntu.
Does anyone else have any advice on build scripts for someone who's never had to worry about linking before?