I'm trying to package a library using the cargo
package manager for Rust. When I try to run cargo package
per the documentation, I get the following output:
error: main function not found
error: aborting due to previous error
failed to verify package tarball
I'm confused. I'm trying to package a library (with useful external functions), so I expect that I don't need a main
function. Here is my Cargo.toml
:
[package]
name = "package-name"
version = "0.0.1"
authors = [ "Kevin Burke <[email protected]>" ]
Here is my directory structure:
.
├── Cargo.lock
├── Cargo.toml
├── src
│ └── main.rs
What am I missing?
Ah! If you are packaging a library for other programs to use (as I am trying to do), you need to name your file lib.rs
.
Alternatively, if you are packaging a binary, name your file main.rs
(this was my mistake).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With