[Solved] Problem with installation Diesel


#1

Hey Guys,
when I try to install Diesel with cargo installer I got this error:

  error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/mehrdad/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.0.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.1.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.10.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.11.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.12.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.13.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.14.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.15.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.2.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.3.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.4.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.5.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.6.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.7.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.8.rcgu.o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.diesel.13qb6gif-cgu.9.rcgu.o" "-o" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202" "/tmp/cargo-installNL7YYl/release/deps/diesel-196cc06361c70202.cxl2exwx4vxf75o.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/tmp/cargo-installNL7YYl/release/deps" "-L" "/usr/lib" "-L" "/tmp/cargo-installNL7YYl/release/build/backtrace-sys-4890e73baf7252bd/out" "-L" "/home/mehrdad/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/cargo-installNL7YYl/release/deps/libtoml-73c35987c27d5659.rlib" "/tmp/cargo-installNL7YYl/release/deps/libtempfile-d73f1b0f09f9ae42.rlib" "/tmp/cargo-installNL7YYl/release/deps/libremove_dir_all-784458688e60fb64.rlib" "/tmp/cargo-installNL7YYl/release/deps/librand-09576e8692173747.rlib" "/tmp/cargo-installNL7YYl/release/deps/librand_xorshift-b0bb25bc8f304a9f.rlib" "/tmp/cargo-installNL7YYl/release/deps/librand_pcg-2324407a3501eabf.rlib" "/tmp/cargo-installNL7YYl/release/deps/librand_hc-9da23ae5ffe28256.rlib" "/tmp/cargo-installNL7YYl/release/deps/librand_chacha-87254a046f8ce656.rlib" "/tmp/cargo-installNL7YYl/release/deps/librand_isaac-de71b677d75ce6d3.rlib" "/tmp/cargo-installNL7YYl/release/deps/librand_core-fc6ae36b06f7081b.rlib" "/tmp/cargo-installNL7YYl/release/deps/libmigrations_internals-1f1d2025b9f7be83.rlib" "/tmp/cargo-installNL7YYl/release/deps/libinfer_schema_internals-60e0772b930b1a0c.rlib" "/tmp/cargo-installNL7YYl/release/deps/libserde-bcabc851d53ee066.rlib" "/tmp/cargo-installNL7YYl/release/deps/libdotenv-a0da32b9a8a35d4c.rlib" "/tmp/cargo-installNL7YYl/release/deps/libregex-585457fdf47d9c73.rlib" "/tmp/cargo-installNL7YYl/release/deps/libutf8_ranges-5197c0af24d17dc8.rlib" "/tmp/cargo-installNL7YYl/release/deps/libregex_syntax-0bea605e4e21046f.rlib" "/tmp/cargo-installNL7YYl/release/deps/libucd_util-1bd3f71b3e49f7f1.rlib" "/tmp/cargo-installNL7YYl/release/deps/libthread_local-1a5314fbcb8ac563.rlib" "/tmp/cargo-installNL7YYl/release/deps/liblazy_static-fec4b28270cf790c.rlib" "/tmp/cargo-installNL7YYl/release/deps/libaho_corasick-5f8ae869b50bba1b.rlib" "/tmp/cargo-installNL7YYl/release/deps/libmemchr-3a9fe13a321fd24e.rlib" "/tmp/cargo-installNL7YYl/release/deps/liberror_chain-95be2ee47e8fa14c.rlib" "/tmp/cargo-installNL7YYl/release/deps/libbacktrace-05bd38dfa75bb7f1.rlib" "/tmp/cargo-installNL7YYl/release/deps/libbacktrace_sys-9dac0cf45f3822c5.rlib" "/tmp/cargo-installNL7YYl/release/deps/librustc_demangle-cf4c8bc0b12fa14f.rlib" "/tmp/cargo-installNL7YYl/release/deps/libcfg_if-47c1d011818ee685.rlib" "/tmp/cargo-installNL7YYl/release/deps/libdiesel-1bd0e935d6935f67.rlib" "/tmp/cargo-installNL7YYl/release/deps/liblibsqlite3_sys-ebb48ed6c6f1715b.rlib" "/tmp/cargo-installNL7YYl/release/deps/libpq_sys-c9a022140dea4f84.rlib" "/tmp/cargo-installNL7YYl/release/deps/liburl-3384d2b27e68a2b4.rlib" "/tmp/cargo-installNL7YYl/release/deps/libpercent_encoding-349533908a0d0f3f.rlib" "/tmp/cargo-installNL7YYl/release/deps/libidna-c28cc7bfec4f7e9f.rlib" "/tmp/cargo-installNL7YYl/release/deps/libunicode_normalization-8dbe223acd30f716.rlib" "/tmp/cargo-installNL7YYl/release/deps/libunicode_bidi-38ae5d84dc3389bb.rlib" "/tmp/cargo-installNL7YYl/release/deps/libmatches-d4785675937e74f2.rlib" "/tmp/cargo-installNL7YYl/release/deps/libmysqlclient_sys-537a6f191b6abd63.rlib" "/tmp/cargo-installNL7YYl/release/deps/libbyteorder-effc474e1cb03e9c.rlib" "/tmp/cargo-installNL7YYl/release/deps/libclap-3b95ebbe5e4783c8.rlib" "/tmp/cargo-installNL7YYl/release/deps/libvec_map-3b7aa31acc29709a.rlib" "/tmp/cargo-installNL7YYl/release/deps/libtextwrap-c427f7be58de0326.rlib" "/tmp/cargo-installNL7YYl/release/deps/libunicode_width-8a2339c20473d916.rlib" "/tmp/cargo-installNL7YYl/release/deps/libstrsim-50379c3fa700f8e9.rlib" "/tmp/cargo-installNL7YYl/release/deps/libbitflags-8584e4e2407a5f55.rlib" "/tmp/cargo-installNL7YYl/release/deps/libatty-3b0b75a23b573c16.rlib" "/tmp/cargo-installNL7YYl/release/deps/libansi_term-92f595c146d82dba.rlib" "/tmp/cargo-installNL7YYl/release/deps/libchrono-72e21fd47a2d6ebe.rlib" "/tmp/cargo-installNL7YYl/release/deps/libnum_integer-1ae4f3d3674545e4.rlib" "/tmp/cargo-installNL7YYl/release/deps/libnum_traits-1ce4af2308b96e79.rlib" "/tmp/cargo-installNL7YYl/release/deps/libtime-6b1b3d5667cdf0e4.rlib" "/tmp/cargo-installNL7YYl/release/deps/liblibc-9b8198c93f376b73.rlib" "-Wl,--start-group" "/home/mehrdad/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-fb388f334f5d7801.rlib" "/home/mehrdad/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-3dae5c5be608ca69.rlib" "/home/mehrdad/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-6b64c7be3c268f85.rlib" "/home/mehrdad/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-92e0b64d1f96f10b.rlib" "/home/mehrdad/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-3413f11e7f7f6c8c.rlib" "/home/mehrdad/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-47abb8688e45050e.rlib" "-Wl,--end-group" "/home/mehrdad/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-8dcceaa68d1c383a.rlib" "-Wl,-Bdynamic" "-lsqlite3" "-lpq" "-lmysqlclient" "-lutil" "-lutil" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
  = note: /usr/bin/ld: cannot find -lpq
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

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

Caused by:
  Could not compile `diesel_cli`.

Caused by:
  process didn't exit successfully: `rustc --crate-name diesel /home/mehrdad/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel_cli-1.3.1/src/main.rs --color always --crate-type bin --emit=dep-info,link -C opt-level=3 --cfg 'feature="default"' --cfg 'feature="diesel"' --cfg 'feature="infer_schema_internals"' --cfg 'feature="mysql"' --cfg 'feature="postgres"' --cfg 'feature="sqlite"' --cfg 'feature="url"' -C metadata=196cc06361c70202 -C extra-filename=-196cc06361c70202 --out-dir /tmp/cargo-installNL7YYl/release/deps -L dependency=/tmp/cargo-installNL7YYl/release/deps --extern chrono=/tmp/cargo-installNL7YYl/release/deps/libchrono-72e21fd47a2d6ebe.rlib --extern clap=/tmp/cargo-installNL7YYl/release/deps/libclap-3b95ebbe5e4783c8.rlib --extern diesel=/tmp/cargo-installNL7YYl/release/deps/libdiesel-1bd0e935d6935f67.rlib --extern dotenv=/tmp/cargo-installNL7YYl/release/deps/libdotenv-a0da32b9a8a35d4c.rlib --extern infer_schema_internals=/tmp/cargo-installNL7YYl/release/deps/libinfer_schema_internals-60e0772b930b1a0c.rlib --extern migrations_internals=/tmp/cargo-installNL7YYl/release/deps/libmigrations_internals-1f1d2025b9f7be83.rlib --extern serde=/tmp/cargo-installNL7YYl/release/deps/libserde-bcabc851d53ee066.rlib --extern tempfile=/tmp/cargo-installNL7YYl/release/deps/libtempfile-d73f1b0f09f9ae42.rlib --extern toml=/tmp/cargo-installNL7YYl/release/deps/libtoml-73c35987c27d5659.rlib --extern url=/tmp/cargo-installNL7YYl/release/deps/liburl-3384d2b27e68a2b4.rlib --cap-lints allow -L native=/usr/lib -L native=/tmp/cargo-installNL7YYl/release/build/backtrace-sys-4890e73baf7252bd/out` (exit code: 1)

may please help me to fix it ?!


#2

You need to install libpq via your package manager (assuming you’re on Linux), so i think under Ubuntu or Debian it should be sudo apt install libpq-dev.
libpq is a C library for interfacing with the PostgreSQL database.


#3

thank you mmmmib :slight_smile:
I must install :
sudo pacman -S libpqxx
now it’s work