Rust
E0463 Can't Find Crate Fix
This error is never about the code that uses the crate. The program can be perfect and still fail, because the failure happens one step earlier: the compiler went looking for a compiled library under the name you gave, in the places it is allowed to look, and found nothing there. Give it the library — by path, by search directory, by its real name, or through a Cargo dependency that links it automatically — and the same program compiles unchanged.
Written November 26, 2026 · Tested with Rust 1.99.1 · 15 min read
- The error: an extern crate with no library behind it
- The crate exists, but it is not on the search path
- The crate is present, but under a different name
- The Cargo case: the dependency was never listed
Written November 26, 2026
Tested with Rust 1.99.1
What this guide is
extern crate greeting; is a request for a compiled library, not a definition and not an import of source code. The compiler resolves that name by scanning its library search path for a compiled crate whose name matches, and E0463 is what it reports when the scan comes back empty: a crate was declared but cannot be found. Nothing in the message points at your logic, because the defect is not in the program — it is in what the compiler was given to link against.
That is why every repair below changes the build, not the code that calls the crate. The same failing program compiles unchanged once the library is supplied in one of four ways: named directly with --extern, found through a directory added with -L, requested under the name the library was actually built with, or pulled in by Cargo because the project's Cargo.toml lists it as a dependency. The shapes differ only in why the scan came back empty — the crate was never built, it was built but is not where the compiler looks, it was built under a different name, or a build tool that would have linked it was never told about it.
The error: an extern crate with no library behind it
This program declares the crate greeting and calls a function from it. No library named greeting has been compiled, and nothing tells the compiler where one would be:
extern crate greeting;
fn main() {
println!("{}", greeting::greet());
}
$ rustc --edition 2021 broken.rs -o broken.bin
error[E0463]: can't find crate for `greeting`
--> broken.rs:1:1
|
1 | extern crate greeting;
| ^^^^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0463`.
Read the span, because it is the whole diagnosis. The caret line covers the entire extern crate declaration and nothing else — not the call in main, not the function name. The compiler is not saying greet is missing; it never got far enough to look inside the crate. The name greeting itself could not be resolved to any compiled library.
The repair starts by actually building the library. This is the whole of the greeting crate — one public function:
pub fn greet() -> &'static str {
"Hello from the greeting crate"
}
Compiled as an rlib under the crate name greeting, it produces the file the first program was asking for:
$ rustc --edition 2021 --crate-type rlib --crate-name greeting greeting_lib.rs -o libgreeting.rlib
That command prints nothing and exits with status 0; its product is libgreeting.rlib on disk. Now the original program compiles, with one addition to the command line — --extern names the crate and the exact file that provides it:
$ rustc --edition 2021 --extern greeting=libgreeting.rlib broken.rs -o broken.bin
$ ./broken.bin
Hello from the greeting crate
The program prints Hello from the greeting crate and exits with status 0. The source file did not change by a single character between the failing compile and this one. What changed is that the compiler was handed the library it had been looking for.
The crate exists, but it is not on the search path
Building the library is not always enough. Here the same greeting library has been compiled and placed in a libs directory next to the program — and the program, identical to the one above, still fails:
extern crate greeting;
fn main() {
println!("{}", greeting::greet());
}
$ rustc --edition 2021 fixed_search.rs -o fixed_search.bin
error[E0463]: can't find crate for `greeting`
--> fixed_search.rs:1:1
|
1 | extern crate greeting;
| ^^^^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0463`.
The library exists on disk, but existence is not what the compiler checks — it scans the directories on its library search path, and libs is not one of them by default. A crate sitting in a directory the compiler never scans is, from the compiler's side, indistinguishable from a crate that was never built.
Adding that directory to the search path with -L is the whole fix:
$ rustc --edition 2021 -L libs fixed_search.rs -o fixed_search.bin
$ ./fixed_search.bin
Hello from the greeting crate
The program prints Hello from the greeting crate and exits with status 0. Choose between this and --extern by how much you want to specify: --extern pins one crate to one exact file, while -L adds a directory to the scan, so every crate in that directory becomes findable under its built name. The official guidance for this error names exactly these two routes — link the code to the relevant crate through Cargo or through the -L option of rustc.
The crate is present, but under a different name
A scan matches on the name the library was built with, not on a name close to it. The library above was built as greeting. This program asks for greetings, one letter more:
extern crate greetings;
fn main() {
println!("{}", greetings::greet());
}
$ rustc --edition 2021 wrong_name.rs -o wrong_name.bin
error[E0463]: can't find crate for `greetings`
--> wrong_name.rs:1:1
|
1 | extern crate greetings;
| ^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0463`.
The error is identical in shape, and the name in its first line is the one clue: it went looking for greetings and found nothing, because nothing was ever built under that name. The library on disk is not missing and not misplaced — the request is misspelled relative to it.
There are two correct endings. The usual one is to fix the name in the source to the name the library was built with. The other, for when the name in the source is the one you want to keep, is to let --extern bind that name to the existing file explicitly:
$ rustc --edition 2021 --extern greetings=libgreeting.rlib wrong_name.rs -o wrong_name.bin
$ ./wrong_name.bin
Hello from the greeting crate
The program prints Hello from the greeting crate and exits with status 0: the name before the = is the name the source uses, and the path after it is the library that satisfies it, whatever that library was originally called. The official page for this error lists this situation directly — the crate is present, but under a different name — and for Cargo projects it points at the package = key under [dependencies], which is where a dependency whose package name differs from the name used in code is reconciled.
The Cargo case: the dependency was never listed
Under Cargo, nobody passes --extern by hand — Cargo builds each listed dependency and passes the right flags to the compiler itself. The mirror-image failure is a project whose code declares a crate that its Cargo.toml never lists. The program:
extern crate greeting;
fn main() {
println!("app says: {}", greeting::greet());
}
The project's manifest, with an empty dependency list:
[package]
name = "app"
version = "0.1.0"
edition = "2021"
[dependencies]
$ cargo build
Compiling app v0.1.0 (/home/droopy/e0463/cargo/app_extern)
error[E0463]: can't find crate for `greeting`
--> src/main.rs:1:1
|
1 | extern crate greeting;
| ^^^^^^^^^^^^^^^^^^^^^^ can't find crate
For more information about this error, try `rustc --explain E0463`.
error: could not compile `app` (bin "app") due to 1 previous error
Cargo compiled the application package and handed the compiler no greeting library, because the manifest never asked for one. The compiler's report is the same E0463 as the hand-driven case — Cargo changes who supplies the library, not what happens when nobody does.
Adding the dependency is the fix. Here the greeting crate is a local package, named in the manifest as a path dependency:
[package]
name = "app"
version = "0.1.0"
edition = "2021"
[dependencies]
greeting = { path = "../greeting_pkg" }
With that line in place, Cargo builds the greeting package first, links it, and the same main.rs runs:
$ cargo run --offline
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s
Running `target/debug/app`
app says: Hello from the greeting crate
The program prints app says: Hello from the greeting crate and exits with status 0. For a dependency from a registry rather than a local path, the entry carries a version instead of a path, but the mechanism is the same: the name in [dependencies] is what makes Cargo build the crate and put it on the compiler's path. The official page for this error puts this case first among its causes — the crate is not present at all, and if using Cargo, add it to [dependencies] in Cargo.toml.
Neighboring case: a use of an unlinked crate is a different error
The same missing library reached through a use declaration instead of an extern crate declaration reports a different code, and the difference matters when you search for help. This program never declares the crate; it imports from it directly, which the 2021 edition allows when the crate is linked:
use greeting::greet;
fn main() {
println!("{}", greet());
}
$ rustc --edition 2021 use_shape.rs -o use_shape.bin
error[E0432]: unresolved import `greeting`
--> use_shape.rs:1:5
|
1 | use greeting::greet;
| ^^^^^^^^ use of unresolved module or unlinked crate `greeting`
|
= help: you might be missing a crate named `greeting`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0432`.
The code is E0432, not E0463, and its label says why: use of unresolved module or unlinked crate greeting. A Cargo project hits the same split — code that uses an unlisted dependency through use fails with E0432 and a help line suggesting cargo add, while code that declares it with extern crate fails with E0463. The underlying problem and the repairs are the same in both reports — link the crate, by --extern, -L, or a [dependencies] entry — but the code in the header tells you which declaration form the compiler was resolving when the lookup failed, and a search keyed on the wrong code lands on the wrong page. E0463 is specifically the extern crate declaration's report: the crate as a whole was declared and could not be found, before any item inside it was ever considered. That is also what separates it from a failed resolution of a module or item path inside a crate that was found.
The exact rule: a declared crate is resolved by name against the library path
The official page for E0463 describes the code in one sentence: a crate was declared but cannot be found. Its erroneous example is a single extern crate foo; with the comment error: can't find crate, and its instruction is to link your code to the relevant crate in order to use it, through Cargo or the -L option of rustc, for example. Its listed causes are the ones reproduced above: the crate is not present at all (under Cargo, add it to [dependencies] in Cargo.toml), and the crate is present but under a different name (under Cargo, look for package = under [dependencies]).
The Reference's page on extern crates states how the name is resolved: an extern crate declaration specifies a dependency on an external crate, and the external crate is resolved at compile time by scanning the compiler's library path and matching the crate name against the names the candidate crates were compiled with — if no crate name is provided, the identifier in the declaration is assumed. That scan is the whole mechanism behind every shape above: no candidate on the path, no match, E0463.
The rustc book's command-line arguments page defines the two hand-driven repairs. -L adds a path to search for external crates and libraries. --extern passes the name and location of an external crate of a direct dependency, in the form CRATENAME=PATH or as a bare CRATENAME to be found in the search path, and the given name is added to the extern prelude much like an extern crate declaration in the root module — with one stated difference: --extern makes the crate a candidate for linking, and it is actually linked only if it is used.
The Cargo book's specifying dependencies page covers the managed route: dependencies are declared in [dependencies] in Cargo.toml, by name with a version requirement for registry crates, or with a path key for a crate in a subdirectory of the local file system, in which case the next build automatically builds that crate and its dependencies. A crate named in code but absent from that list is never built and never linked — which is why the Cargo shape of this error is fixed in the manifest, not in the source.
The fixes, ranked
- First, confirm the crate was ever built. An
extern cratename resolves to a compiled library, never to source files. If there is norlib(or shared library) for the crate, build it first — under Cargo, that means making sure it is a listed dependency so Cargo builds it for you. - Second, under Cargo: check
[dependencies]inCargo.toml. A crate used in code but absent from the manifest is the most common form of this error in a Cargo project; add the entry — a version for a registry crate, apathfor a local one — and rebuild. - Third, with hand-driven rustc: pass
--extern name=path/to/libname.rlibto pin the crate to its exact compiled file. This is the most explicit repair and the one that also resolves a name mismatch, since the name before the=is yours to choose. - Fourth, when a directory holds the libraries: add it with
-L directoryso the scan finds every crate in it under its built name. Prefer this when several crates come from the same place; prefer--externwhen one crate needs one exact file. - Fifth, check the name itself. The name in the declaration, the name the library was built with (
--crate-name, or the package's library name under Cargo), and the name in any--externflag must agree — or be bound together explicitly with--externor, in a manifest, thepackage =key. - Do not delete the
extern crateline or the code that uses the crate to silence the error. The declaration is the symptom's location, not its cause; the cause is always a library the compiler was never given.
Which fix for which cause
| Cause | Message | Fix |
|---|---|---|
| Crate never built or never linked | E0463, can't find crate for greeting |
Build the library, then link it with --extern |
| Library on disk, directory not scanned | E0463, same declaration span | Add the directory with -L libs |
| Name in code differs from built name | E0463, can't find crate for greetings |
Fix the name, or bind it with --extern |
| Cargo project, dependency not in the manifest | E0463 from cargo build, span on extern crate in src/main.rs |
Add the crate to [dependencies] in Cargo.toml |
Unlinked crate reached through use |
E0432, use of unresolved module or unlinked crate | Same linking repairs; the code differs because the declaration form differs |
Checklist
- Read the name in the first line of the error. That is the exact string the compiler searched for — compare it character by character with the name the library was built under, including pluralization and underscores in place of hyphens.
- Check whether a compiled library for that name exists at all. If nothing was ever built, no flag fixes the compile; build the crate first, or add it as a dependency and let Cargo build it.
- Under Cargo, open
Cargo.tomlbefore touching source. If the crate is not under[dependencies], that absence is the bug; if it is there under a different name, look for thepackage =key that reconciles the two. - With hand-driven rustc, decide how the compiler should find the library: one exact file through
--extern name=path, or a directory through-L. Passing neither and expecting a library in an arbitrary folder to be found is the failure itself. - Watch which declaration form you used. An
extern cratedeclaration that cannot be resolved is E0463; auseof an unlinked crate is E0432. Same missing library, different report — search and error indexes are keyed on the code. - After the fix, confirm the program actually uses the crate. The fixed programs here print the value returned by the linked crate's function, from call sites that never changed.
Related guides on this site
- E0401 Can't Use Generic Parameters Fix
- E0434 Can't Capture Environment Fix
- E0604 Only u8 Cast as Char Fix
- E0412 Cannot Find Type Fix
Sources
- Rust Compiler Error Index, E0463 — for a crate being declared but not found, for linking code to the relevant crate through Cargo or the
-Loption of rustc, and for the causes of the crate not being present at all (add it to[dependencies]inCargo.toml) and of it being present under a different name (look forpackage =under[dependencies]). - The Rust Reference, Extern crates — for an
extern cratedeclaration specifying a dependency on an external crate, and for the external crate being resolved at compile time by scanning the compiler's library path and matching the crate name against the names candidate crates were compiled with. - The rustc book, Command-line Arguments — for
-Ladding a path to search for external crates and libraries, and for--externpassing the name and location of an external crate inCRATENAME=PATHor bare-name form, making the crate a candidate that is linked when used. - The Cargo Book, Specifying Dependencies — for dependencies being specified in
[dependencies]inCargo.tomlby name and version requirement, and for path dependencies on crates in subdirectories of the local file system being built automatically by the next build.
Keep Exploring
The full Rust hub \u2014 ownership, structs and enums, async, and measured comparisons.
Every guide on the site in one list, grouped by topic.
Every browser-only checker and verifier on the site.
The C++, Python, Sysadmin, Rust, Go, and TypeScript hubs.