Build Faiss with Rust Link to heading

Following the previous post on building faiss using MKL, here is how to build a rust project that uses faiss crate on Ubuntu

export LIBRARY_PATH=/PATH/TO/FAISS/C_API/ # should contain libfaiss_c.so
export LD_LIBRARY_PATH=/opt/intel/oneapi/mkl/2023.0.0/lib/intel64/

cargo build

If you don’t set the environment variables properly, you will see errors such as

/usr/bin/ld: cannot find -lfaiss_c: No such file or directory

and/or

/usr/bin/ld: warning: libmkl_intel_lp64.so.2, needed by libfaiss.so, not found (try using -rpath or -rpath-link)