New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial roadblock: "Getting Started" PostgreSQL library linking fails on Windows when doing `cargo install diesel_cli --no-default-features postgres` #1883

Open
VermillionAzure opened this Issue Oct 14, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@VermillionAzure

VermillionAzure commented Oct 14, 2018

Setup

Versions

  • Rust: rustc 1.30.0-nightly (cb6d2dfa8 2018-09-16)
  • Diesel: diesel_cli
  • Database: postgres
  • Operating System Windows 10

Feature Flags

  • diesel: postgres

Problem Description

The tutorial is not "smooth" once the user hits this roadblock. Quick Google searches result in not being able to find how to extend the path for cargo install easily. A reasonable person at a beginner level will be stumped, scaring people off of Diesel's tutorial.

Note: adding the bin directory under PostgreSQL in Program Files to my path caused the installation to succeed. Perhaps adding this information to the tutorial might be useful.

What are you trying to accomplish?

Perform installation steps according to the tutorial here: http://diesel.rs/guides/getting-started/

What is the expected output?

Installing the package.

What is the actual output?

PS C:\Users\aytas\my-own-game> cargo install diesel_cli --no-default-features --features postgres
    Updating crates.io index
  Installing diesel_cli v1.3.1
   Compiling proc-macro2 v0.4.20
   Compiling version_check v0.1.5
   Compiling winapi-x86_64-pc-windows-gnu v0.4.0
   Compiling unicode-xid v0.1.0
   Compiling winapi v0.3.6
   Compiling cfg-if v0.1.5
   Compiling num-traits v0.2.6
   Compiling pq-sys v0.4.6
   Compiling unicode-xid v0.0.4
   Compiling libc v0.2.43
   Compiling serde v1.0.79
   Compiling rand_core v0.3.0
   Compiling quote v0.3.15
   Compiling matches v0.1.8
   Compiling ucd-util v0.1.1
   Compiling regex v0.2.11
   Compiling num-integer v0.1.39
   Compiling rustc-demangle v0.1.9
   Compiling bitflags v1.0.4
   Compiling utf8-ranges v1.0.1
   Compiling byteorder v1.2.6
   Compiling unicode-width v0.1.5
   Compiling unicode-normalization v0.1.7
   Compiling vec_map v0.8.1
   Compiling percent-encoding v1.0.1
   Compiling strsim v0.7.0
   Compiling proc-macro2 v0.3.8
   Compiling synom v0.11.3
   Compiling unicode-bidi v0.3.4
   Compiling rand_core v0.2.2
   Compiling regex-syntax v0.5.6
   Compiling memchr v2.1.0
   Compiling lazy_static v1.1.0
   Compiling textwrap v0.10.0
   Compiling syn v0.11.11
   Compiling thread_local v0.3.6
   Compiling aho-corasick v0.6.8
   Compiling quote v0.5.2
   Compiling quote v0.6.8
   Compiling syn v0.13.11
   Compiling backtrace v0.3.9
   Compiling remove_dir_all v0.5.1
   Compiling rand v0.5.5
   Compiling atty v0.2.11
   Compiling time v0.1.40
   Compiling syn v0.15.10
   Compiling error-chain v0.10.0
   Compiling clap v2.32.0
   Compiling chrono v0.4.6
   Compiling derive-error-chain v0.10.1
   Compiling tempfile v3.0.4
   Compiling diesel_derives v1.3.0
   Compiling dotenv v0.10.1
   Compiling serde_derive v1.0.79
   Compiling idna v0.1.5
   Compiling diesel v1.3.3
   Compiling url v1.7.1
   Compiling migrations_internals v1.3.0
   Compiling toml v0.4.8
   Compiling infer_schema_internals v1.3.0
   Compiling diesel_cli v1.3.1
error: linking with `gcc` failed: exit code: 1
  |
  = note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\crt2.o" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "-L" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.0.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.1.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.10.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.11.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.12.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.13.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.14.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.15.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.2.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.3.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.4.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.5.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.6.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.7.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.8.rcgu.o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.diesel.ls5jkkaa-cgu.9.rcgu.o" "-o" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.exe" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\diesel-71a8e8e6ae8b8c99.19ynnub55whocp43.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps" "-L" "C:\\Users\\aytas\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\winapi-x86_64-pc-windows-gnu-0.4.0\\lib" "-L" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\liburl-47c9e5f403f9786f.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libpercent_encoding-96620728ae92a6c9.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libidna-9a127281e20339b6.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libunicode_normalization-438301043f9f1b34.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libunicode_bidi-4d3198a32c1ee328.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libmatches-dbe72a2f8a6e3649.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libtoml-3e06271217709c5b.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libtempfile-dd469f1aee885e38.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libremove_dir_all-a7bf3687111454a7.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\librand-44f452657a2eadf1.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\librand_core-abadbdd4086dca8d.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\librand_core-3ca431ff82320fe3.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libmigrations_internals-d86c4f8d963b090f.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libinfer_schema_internals-223d3f47c9052cbe.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libserde-676ce6c6dacec52e.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libdotenv-bdd9b6715439d4aa.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libregex-799cd9b4b61020eb.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libutf8_ranges-c77eca197b9b604b.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libregex_syntax-757fa543a1553356.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libucd_util-6bafb0e247840aab.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libthread_local-816f4d01ed285cd9.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\liblazy_static-192b3ed7fae32f5e.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libaho_corasick-7eccf30c6641d338.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libmemchr-54f80c7ac919a901.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\liblibc-40d16202f4ef9163.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\liberror_chain-94dbe501f4c653c2.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libbacktrace-65ef0bb676be7e5a.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\librustc_demangle-bcb716b42ab1f4f5.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libcfg_if-8c2ea7cb920285e0.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libdiesel-aa349ccbc6c438a9.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libpq_sys-acc4638ab217c504.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libbyteorder-92c514b3c708d5e3.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libclap-c92c57cc0db73946.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libvec_map-c703a7fe931cd1be.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libtextwrap-17cce0cc74598fd3.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libunicode_width-05bff8ab5ece9a9b.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libstrsim-b480fdc98445b962.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libbitflags-5cfe802ede10325b.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libatty-525f0f218ecdfcd6.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libchrono-095e917bf8b312c5.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libnum_integer-b6c71207e6aed540.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libnum_traits-f0fc12e14078a720.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libtime-030ef2843018c658.rlib" "C:\\Users\\aytas\\AppData\\Local\\Temp\\cargo-install1lmnAV\\release\\deps\\libwinapi-5b2b69bc178c922c.rlib" "-Wl,--start-group" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-d75734fce9de8a47.rlib" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-23bcd7ed267060b8.rlib" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-7bb63bced97b6f87.rlib" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-236b4e813ef04dc3.rlib" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc_system-8a9aab5d37d8ce23.rlib" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-34265d7b30e25ca2.rlib" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-dd2b6f51b2cd5bd7.rlib" "-Wl,--end-group" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-0d29132b5d37b9ad.rlib" "-Wl,-Bdynamic" "-lpq" "-lwinapi_advapi32" "-lwinapi_credui" "-lwinapi_dbghelp" "-lwinapi_gdi32" "-lwinapi_kernel32" "-lwinapi_msimg32" "-lwinapi_opengl32" "-lwinapi_secur32" "-lwinapi_setupapi" "-lwinapi_user32" "-lwinapi_winspool" "-ladvapi32" "-lws2_32" "-luserenv" "-lshell32" "-Wl,-Bstatic" "-lgcc_eh" "-lpthread" "-Wl,-Bdynamic" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-lmsvcrt" "-luser32" "-lkernel32" "C:\\Users\\aytas\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: ld: cannot find -lpq


error: aborting due to previous error

error: failed to compile `diesel_cli v1.3.1`, intermediate artifacts can be found at `C:\Users\aytas\AppData\Local\Temp\cargo-install1lmnAV`

Caused by:
  Could not compile `diesel_cli`.

Are you seeing any additional errors?

No.

Steps to reproduce

  • Install PostgreSQL 10.5.
  • Run the command above.

Checklist

  • I have already looked over the issue tracker for similar issues.
  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
@weiznich

This comment has been minimized.

Contributor

weiznich commented Oct 15, 2018

Feel free to submit a PR to https://github.com/sgrif/diesel.rs-website extending the note section there to directly list which native dependencies are required for which backends.

@top1st

This comment has been minimized.

top1st commented Nov 8, 2018

copy C:/PostgreSQL/pg10/lib/libpq.dll & libpq.a to $(HOME)/.rustup/toolchains/[stable--msvc,gun]/lib/rustlib/x86/64-pc-windows.../lib
rename libpq.a -> libpq.lib

next compile works

@top1st

This comment has been minimized.

top1st commented Nov 8, 2018

Here is one issue diesel migration run not works well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment