Sqlite and the Missing .lib File
When I attempted to use the sqlite crate recently, I was surprised to see the following error when I attempted to build my project:
error: linking with `link.exe` failed: exit code: 1181
...
= note: LINK : fatal error LNK1181: cannot open input file 'sqlite3.lib'
Short of building sqlite3 myself, which I wasn’t overly keen on doing for what should be a small portable little util, I wasn’t too sure what to do. Luckily, thanks to the power of the interwebs, someone has already solved this particular issue.
I can’t lay claim to having solved this, but to summarise briefly if you’re too lazy to click a link, the solution is to embed sqlite in your compiled output. To do this, add the following to your cargo.toml:
[dependencies.sqlite3-src]
version="0.3"
features=["bundled"] # This is the important bit!
This is the version that’s used by the sqlite crate, after following the dependency chain from sqlite -> sqlite3-sys -> sqlite3-src. Once you’ve worked out the right version to specify in your cargo.toml, telling it to bundle sqlite in your build means that you no longer need to provide access to a pre-compiled sqlite3 library.