< 返回版块

Zac.R 发表于 2021-05-30 08:26

安装diesel时出错,报错如下,请问怎么解决,Gcc已经安装了

$cargo install diesel_cli --no-default-features --features sqlite
    Updating crates.io index
  Installing diesel_cli v1.4.1
   Compiling libc v0.2.95
   Compiling autocfg v1.0.1
   Compiling proc-macro2 v1.0.27
   Compiling unicode-xid v0.2.2
   Compiling cfg-if v1.0.0
   Compiling syn v1.0.72
   Compiling pkg-config v0.3.19
   Compiling cc v1.0.68
   Compiling memchr v2.4.0
   Compiling adler v1.0.2
   Compiling gimli v0.24.0
   Compiling unicode-xid v0.0.4
   Compiling serde_derive v1.0.126
   Compiling ppv-lite86 v0.2.10
   Compiling object v0.24.0
   Compiling rustc-demangle v0.1.19
   Compiling regex v0.2.11
   Compiling serde v1.0.126
   Compiling lazy_static v1.4.0
   Compiling ucd-util v0.1.8
   Compiling quote v0.3.15
   Compiling bitflags v1.2.1
   Compiling utf8-ranges v1.0.4
   Compiling byteorder v1.4.3
   Compiling unicode-width v0.1.8
   Compiling vec_map v0.8.2
   Compiling ansi_term v0.11.0
   Compiling strsim v0.8.0
   Compiling remove_dir_all v0.5.3
   Compiling miniz_oxide v0.4.4
   Compiling num-traits v0.2.14
   Compiling num-integer v0.1.44
   Compiling libsqlite3-sys v0.20.1
   Compiling synom v0.11.3
   Compiling thread_local v0.3.6
   Compiling regex-syntax v0.5.6
   Compiling backtrace v0.3.59
   Compiling textwrap v0.11.0
   Compiling addr2line v0.15.1
   Compiling syn v0.11.11
   Compiling quote v1.0.9
   Compiling aho-corasick v0.6.10
   Compiling getrandom v0.2.3
   Compiling atty v0.2.14
   Compiling time v0.1.43
   Compiling rand_core v0.6.2
   Compiling clap v2.33.3
   Compiling error-chain v0.10.0
   Compiling rand_chacha v0.3.0
   Compiling chrono v0.4.19
   Compiling rand v0.8.3
   Compiling derive-error-chain v0.10.1
   Compiling tempfile v3.2.0
   Compiling dotenv v0.10.1
   Compiling diesel_derives v1.4.1
   Compiling diesel v1.4.6
   Compiling toml v0.4.10
   Compiling migrations_internals v1.4.1
   Compiling diesel_cli v1.4.1
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.0.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.1.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.10.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.11.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.12.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.13.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.14.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.15.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.2.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.3.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.4.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.5.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.6.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.7.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.8.rcgu.o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.diesel.3xr2qst2-cgu.9.rcgu.o" "-o" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e" "/tmp/cargo-installoM3dwE/release/deps/diesel-7ba38a9682847f8e.1gbf7ubksucq1ujd.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/tmp/cargo-installoM3dwE/release/deps" "-L" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/cargo-installoM3dwE/release/deps/libtoml-55133409fe0beefe.rlib" "/tmp/cargo-installoM3dwE/release/deps/libtempfile-1e3f4ae5650ed317.rlib" "/tmp/cargo-installoM3dwE/release/deps/librand-fb73055012b955af.rlib" "/tmp/cargo-installoM3dwE/release/deps/librand_chacha-ab8c6689e11e0975.rlib" "/tmp/cargo-installoM3dwE/release/deps/libppv_lite86-6d65781791a3d15c.rlib" "/tmp/cargo-installoM3dwE/release/deps/librand_core-1f5399cf48fcaa0b.rlib" "/tmp/cargo-installoM3dwE/release/deps/libgetrandom-f320ab28fe334a8f.rlib" "/tmp/cargo-installoM3dwE/release/deps/libremove_dir_all-e2cbe2b2d411b55e.rlib" "/tmp/cargo-installoM3dwE/release/deps/libserde-de236bbb5f0fac6f.rlib" "/tmp/cargo-installoM3dwE/release/deps/libmigrations_internals-869976cb9ca4d827.rlib" "/tmp/cargo-installoM3dwE/release/deps/libdotenv-1c74b51b15f32a61.rlib" "/tmp/cargo-installoM3dwE/release/deps/libregex-e477eabdc124a0d1.rlib" "/tmp/cargo-installoM3dwE/release/deps/libutf8_ranges-460c79a64529faaa.rlib" "/tmp/cargo-installoM3dwE/release/deps/libregex_syntax-a6fa55406fd86e40.rlib" "/tmp/cargo-installoM3dwE/release/deps/libucd_util-6e6167ece8a900b4.rlib" "/tmp/cargo-installoM3dwE/release/deps/libthread_local-8b644c5860a03551.rlib" "/tmp/cargo-installoM3dwE/release/deps/liblazy_static-9ddb64e414b58b19.rlib" "/tmp/cargo-installoM3dwE/release/deps/libaho_corasick-0d35eca46e878707.rlib" "/tmp/cargo-installoM3dwE/release/deps/libmemchr-7e256388be913362.rlib" "/tmp/cargo-installoM3dwE/release/deps/liberror_chain-b89ad4f1bf021b5a.rlib" "/tmp/cargo-installoM3dwE/release/deps/libbacktrace-5039f4029ee5c3ab.rlib" "/tmp/cargo-installoM3dwE/release/deps/libminiz_oxide-065dd38be0f2fe85.rlib" "/tmp/cargo-installoM3dwE/release/deps/libadler-4dbc235c5e8f9f49.rlib" "/tmp/cargo-installoM3dwE/release/deps/libobject-6853f53d69c2beec.rlib" "/tmp/cargo-installoM3dwE/release/deps/libaddr2line-f003e31a0cb61230.rlib" "/tmp/cargo-installoM3dwE/release/deps/libgimli-360097579a632e6a.rlib" "/tmp/cargo-installoM3dwE/release/deps/libcfg_if-048c2fa9f5217d0e.rlib" "/tmp/cargo-installoM3dwE/release/deps/librustc_demangle-bfe0581d0b0adcb8.rlib" "/tmp/cargo-installoM3dwE/release/deps/libdiesel-8f45bb1ec659612a.rlib" "/tmp/cargo-installoM3dwE/release/deps/liblibsqlite3_sys-2b904880b4954b5e.rlib" "/tmp/cargo-installoM3dwE/release/deps/libbyteorder-7b510a648ddfabfd.rlib" "/tmp/cargo-installoM3dwE/release/deps/libclap-a24bff80c7cc1a62.rlib" "/tmp/cargo-installoM3dwE/release/deps/libvec_map-e53d344f35f15332.rlib" "/tmp/cargo-installoM3dwE/release/deps/libtextwrap-b2657c542f79ab43.rlib" "/tmp/cargo-installoM3dwE/release/deps/libunicode_width-af82d4e91c8cb3f3.rlib" "/tmp/cargo-installoM3dwE/release/deps/libstrsim-0d1f8cf1033faa1d.rlib" "/tmp/cargo-installoM3dwE/release/deps/libbitflags-29209152dba883f0.rlib" "/tmp/cargo-installoM3dwE/release/deps/libatty-2569b1293b756fb8.rlib" "/tmp/cargo-installoM3dwE/release/deps/libansi_term-f005afac3df4008e.rlib" "/tmp/cargo-installoM3dwE/release/deps/libchrono-773fe422a8d41847.rlib" "/tmp/cargo-installoM3dwE/release/deps/libnum_integer-174f8f33258eb4d0.rlib" "/tmp/cargo-installoM3dwE/release/deps/libnum_traits-500a1927a0b440ef.rlib" "/tmp/cargo-installoM3dwE/release/deps/libtime-821dbb12392f0d40.rlib" "/tmp/cargo-installoM3dwE/release/deps/liblibc-c07fa84751cf627a.rlib" "-Wl,--start-group" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-0a9489cf400f65e4.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-ff5dc44c66f8c479.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-3317c66a83501f9c.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-5d8dec11fc25537d.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-3af2a9328550e2a6.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-3092e2ecef0f49f1.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-29b776c021389465.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-e8873bd287db0d28.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-1171b49d77e47426.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-c29894d22dc88b51.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-796a7750df3d8218.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-ff7772d803d3e0de.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-dae3eac9cfa44200.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-0fa02f580e987af5.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-7f7254233be843ed.rlib" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-1395c6db3d116086.rlib" "-Wl,--end-group" "/home/zac/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-b4bd87926720b651.rlib" "-Wl,-Bdynamic" "-lsqlite3" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
  = note: /usr/bin/ld: cannot find -lsqlite3
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at `/tmp/cargo-installoM3dwE`

Caused by:
  could not compile `diesel_cli`

To learn more, run the command again with --verbose.

在创建的项目中执行cargo run报错如下:

$ cargo run
error: multiple packages link to native library `sqlite3`, but a native library can be linked only once

package `libsqlite3-sys v0.9.1`
    ... which is depended on by `diesel v1.4.6`
    ... which is depended on by `actix_diesel v0.1.0 (/mnt/e/desktop/project/rust/actix_diesel)`
links to native library `sqlite3`

package `libsqlite3-sys v0.22.2`
    ... which is depended on by `rusqlite v0.25.3`
    ... which is depended on by `actix_diesel v0.1.0 (/mnt/e/desktop/project/rust/actix_diesel)`
also links to native library `sqlite3`

toml文件依赖如下

[dependencies]
actix-web = "3"
diesel = {version = "1.4.5",features = ["sqlite", "r2d2"]}
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
anyhow = "1.0"
chrono = "0.4.1"
dotenv = "0.15"
rusqlite = {version = "0.25.3", features = ["bundled"]}

评论区

写评论
AlephAlpha 2021-06-14 18:13

diesel命令行要本地装sqlite。

项目中依赖diesel的话要看清楚所用的diesel版本所依赖的libsqlite3-sys版本。

前几天diesel 1.4.7出了,libsqlite3-sys可以用当前的最新版了。

wangbinyq 2021-05-31 09:39

diesel = { version="1.4.6", features= ["sqlite"] } libsqlite3-sys = { version="0.20.1", features = ["min_sqlite_version_3_7_16", "bundled"] }

rex-ma-2015 2021-05-30 11:49

这个要装sqlite3,你下载sqlite源代码后,make install 就可以了。 rust 现在访问数据库很坑,不像java,golang一般都没有rust版的驱动,都是通过c/c++的库来访问的。

1 共 3 条评论, 1 页