Using rlibs in rust

hey I've been trying to compile an rlib into my project.

cargo.toml
[dependencies]

rlibtest = {"path"="../liblibtest"}

but i get this

indent preformatted text by 4 spaces
rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file 
c:\Users\135408\Workspace\playground\bintest\Cargo.toml, cargo 1.52.0 (69767412a 2021-04-21):    
Failed to run `cargo metadata --manifest-path 
c:\Users\135408\Workspace\playground\bintest\Cargo.toml` in 
`c:\Users\135408\Workspace\playground\bintest`: `cargo metadata` exited with an error: error: failed 
to get `rlib` as a dependency of package `bintest v0.1.0 
(C:\Users\135408\Workspace\playground\bintest)` Caused by: failed to load source for dependency 
`rlib` Caused by: Unable to update C:\Users\135408\Workspace\playground\liblibtest Caused by: 
 failed to read `C:\Users\135408\Workspace\playground\liblibtest\Cargo.toml` Caused by: The 
 system 
 cannot find the path specified. (os error 3)

dependencies expects a Cargo package, which it will build as part of the larger build.
An rlib is the final product of a compilation step. Cargo passes them around under the hood to rustc.

So the question is: what are you really trying to do there? What does your project look like and why do you think using an rlib directly is the way to go?

You can't use rlib with Cargo. Rust doesn't have a stable ABI, so you pretty much can't use them at all. Threat them as an internal implementation detail of Rust that is not for users.

well I'm making a game engine and i wanted to use a static library to share it across projects compared to having cargo install it as a dependency every single time. And in the built version I wanted to compile the library into the binary.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.