Rust 配置 diesel 庫 Windows 上安裝配置 (postgres、sqlite、mysql)解決diesel_cli報錯或安裝完后無法正常運行


Rust 配置 diesel 庫 Windows 上安裝配置 (postgres、sqlite、mysql)解決diesel_cli報錯或安裝完后無法正常運行


 

在被 rust-postgresql 折磨之后,選擇了 diesel 庫,這才了解到 對象關系映射(Object Relational Mapping, ORM) ,
可以像使用本地變量和函數一樣操作關系型數據庫。這有點像非關系型數據庫(如MongoDB)操作方式的意味,不過不知道孰先孰后。
diesel 提供了一個叫 diesel_cli 的工具,用來將 MySQL、PostgreSQL 或 Sqlite 上的數據表結構轉換成代碼
 
網上教程有點即使讓你正常的安裝完這個diesel_cli但依舊無法在windows上成功編譯,原因是依賴另一些dll鏈接庫,可能是最新版的緣故。
報錯:
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "/* 省略一些鏈接參數 */"
  = note: LINK : fatal error LNK1181: cannot open input file 'libpq.lib'
error: aborting due to previous error
 
error: failed to compile `diesel_cli v1.4.0`, intermediate artifacts can be found at `C:\Users\sunnysab\AppData\Local\Temp\cargo-installhOpejX`
 
Caused by:
  could not compile `diesel_cli`.
To learn more, run the command again with --verbose.
網上不是我說解決方法治標不治本,這個解決了又來新的問題!
 
postgresql解決辦法
postgresql安裝包 https://www.postgresql.org/download/windows/
推薦二進制包,這樣后面直接可以配置docker。
postgresql 二進制包 https://www.enterprisedb.com/download-postgresql-binaries
 
Mysql 的解決方案
這里選擇對應的框架,並下載個zip包就可以。解壓出來。 https://downloads.mysql.com/archives/c-c/
 
SQLite 解決方案 (暫時未解決)
如果不同框架就點擊此連接https://www.sqlite.org/download.html
用了匯編DOSBox編和masm編譯sqlite3.lib  調用的時候還是報錯未解決。
如果有能解決SQLite的請聯系我
我需要將lib(libpg.lib)和pgAdmin 4/bin(.dll)的依賴給映射出來
 
 
// 如果要配置sqlite則執行下面命令
cargo install diesel_cli --no-default-features --features “sqlite-bundled”
// postgres配置 
argo install diesel_cli --no-default-features --features postgres
// mysql配置
argo install diesel_cli --no-default-features --features mysql
 
 
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM