I am building a library in Rust that is called from C / C ++ code. Cargo.toml configured to display the box as a static library:
[lib] crate-type = ["staticlib"]
I have a test in tests/integration_test.rs :
extern crate mylibrary; #[test] fn it_works() { hello_world();
However, when running tests with cargo test following error is displayed:
error[E0463]: can't find crate for `mylibrary` --> tests\integration_test.rs:1:1 | 1 | extern crate mylibrary; | ^^^^^^^^^^^^^^^^^^^^^ can't find crate
If I remove the staticlib configuration line from Cargo.toml , then the tests build and work fine.
Two possibilities come to me:
Do I need to configure the construction of the box when performing tests in different ways (i.e. so that it does not create a static library)?
Do I need to link the static library box differently in the test (i.e. as if it were a C system library)?
Itβs not clear from the docs what the correct way to configure this setting, or how to do it.
source share