I'm building a Rust project using Diesel and PostgreSQL. I run PostgreSQL in Docker (I don't have it installed locally). I successfully ran diesel migration run
, and my tables were created. However, when I run main.rs
, I get a database connection error. Some sources suggest installing PostgreSQL on my computer, but I prefer to connect to the Docker container instead. My PostgreSQL container exposes port 5432 to localhost, and my DATABASE_URL
is set correctly. How can I make my Rust application connect to the Dockerized PostgreSQL without needing to install PostgreSQL locally?
error: linking with `link.exe` failed: exit code: 1181
|
= note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.43.34808\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\vucon\\AppData\\Local\\Temp\\rustcpQYWIB\\symbols.o" "<257 object files omitted>" "D:\\Desktop\\Rust_learning\\axum_learning\\rest-api\\target\\debug\\deps/{libtower_http-6462bec82fa67a71.rlib,libthiserror-ada364c7e90c1375.rlib,libaxum-df7ba45e28c6e1a6.rlib,libserde_path_to_error-4971e1e27d0231ef.rlib,libserde_json-cb1da7e646488faf.rlib,libmemchr-105646b5756cb14a.rlib,libserde_urlencoded-2bbff12e817fd7ac.rlib,libryu-6ac78a988ab9ad86.rlib,libform_urlencoded-da3d6eb3563d5673.rlib,libpercent_encoding-36355d0f5ec6ec70.rlib,libhyper_util-f9ae3f61d33e24cf.rlib,libhyper-e85c493d5d598cbc.rlib,libhttparse-7a9cf2ec73ddb78e.rlib,libhttpdate-9257db76ad17ff29.rlib,libfutures_channel-93866827f40b93b5.rlib,libmatchit-b1ee7651a4c4350d.rlib,libaxum_core-d9bd6a15c824975a.rlib,libmime-64a84b31f0e207ba.rlib,libhttp_body_util-81e2f8873bbddae5.rlib,libhttp_body-8168f001b9181e42.rlib,libhttp-67027ffbacbd833d.rlib,libfnv-98890e3ff67f2430.rlib,libtracing-4cdc890f2430aa43.rlib,libtracing_core-0bc12b3517250cf2.rlib,libonce_cell-ecc86b59685e8d56.rlib,libtower-90472a8e3c7cb4d8.rlib,libsync_wrapper-0d8ee7e588523c9c.rlib,libtower_layer-e54a78936e51308c.rlib,libfutures_util-009079feb21fbd9c.rlib,libfutures_task-fbfcf4d036a68d48.rlib,libpin_utils-8ff768994ab1a462.rlib,libfutures_core-b17e2c2a87306059.rlib,libtower_service-85c893f18d7f8b9f.rlib,libtokio-4bce4dd606e2c9cd.rlib,libsocket2-9197175e17c66b74.rlib,libbytes-6e1b71233944c901.rlib,libmio-7175e77e6bc0752a.rlib,libwindows_sys-2e3ee3fb155c4693.rlib,libpin_project_lite-efc1287e85ca2a83.rlib,libdotenv-a9bb7153f3c10c70.rlib,libdiesel-e6ad1868f441784d.rlib,libitoa-04f76355b1fc7079.rlib,libuuid-0e64a0b23aa5d3e0.rlib,libgetrandom-6dd0dcc646dd2d5b.rlib,libbitflags-a3b4274c99baa24d.rlib,libbyteorder-d8a0d051f37c2508.rlib,libr2d2-a823a597fe23f285.rlib,libscheduled_thread_pool-6c0cc37e34e78192.rlib,libparking_lot-a40c2ccb06799a8e.rlib,libparking_lot_core-58d6319ea9288dbf.rlib,libwindows_targets-dd8cca008988cf75.rlib,libcfg_if-120b7212e7bc72ec.rlib,libsmallvec-56b34d4bd689d4b5.rlib,liblock_api-6f116e7c0c710338.rlib,libscopeguard-4a1404f096e49870.rlib,liblog-c603d8f956e435cc.rlib,libpq_sys-fe47be3258112a90.rlib,liblibc-c6c2bba6b066e08d.rlib,libchrono-7347488291da9dab.rlib,libnum_traits-e5ee96478b9d9bfe.rlib,libwindows_link-7d8b2e9c4c517ee5.rlib,libserde-f15b906c267b102d.rlib}.rlib" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib/{libstd-*,libpanic_unwind-*,libwindows_targets-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libunwind-*,libcfg_if-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "C:\\Users\\vucon\\.cargo\\registry\\src\\index.crates.io-1949cf8c6b5b557f\\windows_x86_64_msvc-0.52.6\\lib\\windows.0.52.0.lib" "C:\\Users\\vucon\\.cargo\\registry\\src\\index.crates.io-1949cf8c6b5b557f\\windows_x86_64_msvc-0.52.6\\lib\\windows.0.52.0.lib" "libpq.lib" "legacy_stdio_definitions.lib" "kernel32.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/LIBPATH:C:\\Users\\vucon\\.cargo\\registry\\src\\index.crates.io-1949cf8c6b5b557f\\windows_x86_64_msvc-0.52.6\\lib" "/OUT:D:\\Desktop\\Rust_learning\\axum_learning\\rest-api\\target\\debug\\deps\\rest_api.exe" "/OPT:REF,NOICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libstd.natvis"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: LINK : fatal error LNK1181: cannot open input file 'libpq.lib'␍