Linking to CUDA Library in Leaf

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 just contains the following:

fn main() {

Dodgy but it works :smiley:

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?

The pkg-config crate can do most of the heavy lifting for since CUDA comes with a pkg-config file, though collenchyma should really be handling that for you. You might want to open an issue on that repo.

Thanks, I don't really understand it all yet, but are you saying that collenchyma should use something like pkg-config to link to CUDA when using that feature?

I'll open an issue for it.


That depends on the distro/provided package doesn't it? Here on Arch Linux I don't have a pkg-config file for CUDA.

cudnn definitely no package , looked on ubuntu and mint. ( nor cuda 7.5)