linker error undefined reference when using a C library
Trying to bind a small C library via extern "C" on Linux (Ubuntu 22.04, rustc 1.78). Code compiles but linking fails:
error: linking with cc failed: exit status: 1
= note: /usr/bin/ld: cannot find -lfoo
collect2: error: ld returned 1 exit status
I added #[link(name = "foo")] on the extern block. The library is at /usr/local/lib/libfoo.so. What am I missing?
4 replies