Description
I am not sure if this is a bug or not, but after upgrading nightly versions,I keep getting this error:
ld: library 'ffi_lib' not found
when trying to build a Rust Cucumber test containing a FFI library. Any help in either getting this resolved or fixed would be greatly appreciated.
So we have a cucumber test crate that tests an FFI crate.
The project structure looks as follows:
root
+---base
+---ffi_lib
+---cargo.toml
+---integration_tests
+---cargo.toml
We include the FFI library in the cargo.toml file with :
ffi_lib = { path = "../base/ffi_lib" }
Then its linked into the code via:
#[link(name = "ffi_lib")]
extern "C" {
pub fn create_vector(tag: TTypeTag) -> *mut TVector;
The cargo.toml
of ffi_lib contains this:
[lib]
crate-type = ["staticlib", "cdylib"]
Now this code works on Rust nightly-2024-08-03
and earlier, but as soon as you increase the version to nightly-2024-08-04
or later it breaks with:
error: linking with `cc` failed: exit status: 1
note: "cc" "/var/folders/47/s7....{}
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: ld: warning: ignoring duplicate libraries: '-liconv'
ld: library 'ffi_lib' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am struggling to find what rustc versions are used by these nightly version or docs about what could have changed. For what its worth this was done on a Mac M1, but fails on Unix CI as well with the same issue, so I doubt its a OSX only issue.
I can also see the ffi_lib
library is built, and all its files are in the target folder.
Also
Running cargo +nightly-2025-05-01 test --all-features --release -v
I can see that rustc is adding in the -lffi_lib
flag to include the library.