英文:
What is the missing 'sqlite3.lib' file when trying to run rustqlite with precompiled binary on Windows 11?
问题
我对Rust生态系统不太熟悉,请注意。我尝试使用rustqlite crate来存储非常大的索引,这些索引无法放入内存中。我立即遇到了运行时错误,其中出现了故障并显示:
= 注意:LINK:致命错误LNK1181:无法打开输入文件'sqlite3.lib'
我正在使用预编译的sqlite3 windowsx86二进制文件,我只有一个名为"tokens.db"的文件,以及sqlite3.exe。sqlite3.lib应该是什么?我没有找到任何信息性的视频或搜索结果,甚至安装了全新的MS构建工具等。
Rust代码本身没有编译器错误,看起来似乎没什么问题。我期待着任何关于如何解决这个问题的见解。
英文:
I'm new to the rust ecosystem bare in mind. I'm trying to use rustqlite crate so I can store really large indexes that don't fit into memory. I get an immediate RUNTIME ERROR where it faults and says:
= note: LINK : fatal error LNK1181: cannot open input file 'sqlite3.lib'
linking with `link.exe` failed: exit code: 1181
I'm using the precompiled binary for sqlite3 windowsx86 and I only have a "tokens.db" along with my sqlite3.exe. What is the sqlite3.lib supposed to be? I've found no informative videos or searching and I've even installed brand new MS build tools and etc.
The rust code itself has no compiler errors and seems to look okay. I look forward to any insight on how to fix this
答案1
得分: 1
在 cargo.toml
中做简单修复,正如 @pigeonhands 指出的。我所需要做的就是在 rustqlite
依赖中指定 features 为 bundled 选项。
rusqlite = { version = "0.29.0", features = ["bundled"] }
写入数据库变得非常慢,但除此之外,现在一切都正常了,谢谢。
英文:
Simple fix in the cargo.toml
as @pigeonhands pointed out. All I had to do was specify the features bundled option in the rustqlite
dependency.
rusqlite = { version = "0.29.0", features = ["bundled"] }
Getting super slow writes to my DB but other than that works now thanks.
答案2
得分: 0
sqlite3.lib
是一个静态库。
以下内容适用于 diesel
以解决相同的错误,我假设对于 rusqlite
也适用。如果不是这种情况,请告诉我。
如果您不想使用捆绑的依赖项,而是想使用全局的依赖项,那么您可以在 cmd 中执行以下操作(不是 Powershell):
choco install sqlite
cd C:\ProgramData\chocolatey\lib\SQLite\tools
call "C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
lib /machine:x64 /def:sqlite3.def /out:sqlite3.lib
要使用 choco
,您需要安装 Chocolately(您也可以通过 Node.js 安装 Chocolately,也许您已经安装了它)。
您可以通过 Visual Studio Installer 获取那个 .bat
文件,并安装 "Desktop development with C++" Workload。
您还可以从 SQLite 网站下载 64 位 DLL(x64)的 .def
文件,版本为 3.42.0,而不是使用 Chocolately,但是在使用这种方法时,您还需要执行 .bat
文件,只是跳过了安装包管理器(Chocolately)。
然后在执行 cargo
命令之前,在 Windows Powershell 中执行以下操作:
$Env:SQLITE3_LIB_DIR = "<path-to-folder-where-sqlite3-dot-lib-lives>"
然后执行您的 cargo
命令(例如 cargo test
)。
英文:
sqlite3.lib
is a static library.
The following works with diesel
for the same error, I assume it also works for rusqlite
. If this is not the case, please let me know.
If you do not want to use a bundled dependency, but instead a global one, then you do the following within a cmd (not Powershell):
choco install sqlite
cd C:\ProgramData\chocolatey\lib\SQLite\tools
call "C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
lib /machine:x64 /def:sqlite3.def /out:sqlite3.lib
In order to use choco
you need to install Chocolately (you can also install Chocolately via Node.js, maybe you already have it installed).
You can get that .bat
file via the Visual Studio Installer and installing the "Desktop development with C++" Workload.
You can also download the .def
file from the SQLite website via the 64-bit DLL (x64) for SQLite version 3.42.0 Download instead of using Chocolately, but when using that approach you also need to execute the .bat
file, you just skip installing a package manager (Chocolately).
Then do the following within Windows Powershell before you execute your cargo
command.
$Env:SQLITE3_LIB_DIR = "<path-to-folder-where-sqlite3-dot-lib-lives>"
Then execute your cargo
command (for example cargo test
).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论