#Cannot make Rust bindings for a C library

5 messages · Page 1 of 1 (latest)

woven crow
#

So I have a libnumpulate.a file on a lib folder. I want my lib.rs file to be able to use the functions in my C library.

My filesystem looks like this:

- lib
  - libnumpulate.a
- src
  - lib.rs

How do I get my lib.rs access libnumpulate.a?

brittle portal
#

the process of using C functions in rust is called c binding , what you have to do :

#

when compiling you need to provide the path to your libnumpulate.a file to rust compiler

#

one way to do it is by adding a file called build.rs at the root of your project and put inside it fn main() { println!("cargo:rustc-link-search=PATH_to_lib/libnumpulate.a); println!("cargo:rustc-link-lib=static=test"); }