rust call sqlite3 error: linking with `link.exe` failed: exit code: 1181

rust call sqlite3 error: linking with link.exe failed: exit code: 1181

声明:本文禁止csdn.net及所有所有子网站转载。禁止以营利性为目的的转载。

报错

error: linking with `link.exe` failed: exit code: 1181
|
= note: ...
....
= note: LINK : fatal error LNK1181: 无法打开输入文件“sqlite3.lib”
warning: `demo` (bin "demo") generated 1 warning
error: could not compile `demo` (bin "demo") due to previous error; 1 warning emitted

Cargo.toml

[package]
name = "demo"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rusqlite = { version = "0.30.0", features = ["winsqlite3"] }

src/main.rs

use rusqlite::{Connection, Result};
#[derive(Debug)]
struct Person {
id: i32,
name: String,
data: Option<Vec<u8>>,
}
fn main() -> Result<()> {
let conn = Connection::open("person.db")?;
conn.execute(
"CREATE TABLE person (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
data BLOB
)",
(), // empty list of parameters.
)?;
let me = Person {
id: 0,
name: "Roc".to_string(),
data: None,
};
conn.execute(
"INSERT INTO person (name, data) VALUES (?1, ?2)",
(&me.name, &me.data),
)?;
let mut stmt = conn.prepare("SELECT id, name, data FROM person")?;
let person_iter = stmt.query_map([], |row| {
Ok(Person {
id: row.get(0)?,
name: row.get(1)?,
data: row.get(2)?,
})
})?;
for person in person_iter {
println!("Found person {:?}", person.unwrap());
}
Ok(())
}

通过添加winsqlite3特性来解决:

cargo add rusqlite --features winsqlite3
posted @   咕咚!  阅读(262)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示