mdbx: Unable to compile on windows
Closed this issue · 4 comments
Hi, thank you for making this crate. It's a pleasure to with this crate.
But unfortunately, I am unable to compile my program on windows when using the mdbx
backend. I am getting the following error.
Also, when I compile with the default features i.e lmdb
It compiles just fine.
- Error
error: linking with `link.exe` failed: exit code: 1120
|
= note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Rust\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "D:\\a\\ky\\ky\\target\\x86_64-pc-windows-msvc\\release\\deps\\ky.ky.56mjjk9i-cgu.0.rcgu.o" "/OUT:D:\\a\\ky\\ky\\target\\x86_64-pc-windows-msvc\\release\\deps\\ky.exe" "/OPT:REF,ICF" "/DEBUG" "/NATVIS:C:\\Rust\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Rust\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Rust\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Rust\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis" "/LIBPATH:D:\\a\\ky\\ky\\target\\x86_64-pc-windows-msvc\\release\\deps" "/LIBPATH:D:\\a\\ky\\ky\\target\\release\\deps" "/LIBPATH:D:\\a\\ky\\ky\\target\\x86_64-pc-windows-msvc\\release\\build\\mdbx-sys-2c7e90a2ee211e79\\out" "/LIBPATH:D:\\a\\ky\\ky\\target\\x86_64-pc-windows-msvc\\release\\build\\zstd-sys-8deae39dfcf40489\\out" "/LIBPATH:C:\\Rust\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\rustcaoipm6\\libzstd_sys-c946d6399ca63c58.rlib" "C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\rustcaoipm6\\libmdbx_sys-5fd7a177ed6819e6.rlib" "C:\\Rust\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-c115f0a110b00510.rlib" "bcrypt.lib" "advapi32.lib" "cfgmgr32.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "ole32.lib" "opengl32.lib" "shell32.lib" "user32.lib" "winspool.lib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "libcmt.lib"
= note: Creating library D:\a\ky\ky\target\x86_64-pc-windows-msvc\release\deps\ky.lib and object D:\a\ky\ky\target\x86_64-pc-windows-msvc\release\deps\ky.exp
libmdbx_sys-5fd7a177ed6819e6.rlib(mdbx.o) : error LNK2019: unresolved external symbol NtClose referenced in function mdbx_mmap
libmdbx_sys-5fd7a177ed6819e6.rlib(mdbx.o) : error LNK2019: unresolved external symbol NtQuerySystemInformation referenced in function mdbx_osal_bootid
libmdbx_sys-5fd7a177ed6819e6.rlib(mdbx.o) : error LNK2019: unresolved external symbol NtCreateSection referenced in function mdbx_mmap
libmdbx_sys-5fd7a177ed6819e6.rlib(mdbx.o) : error LNK2019: unresolved external symbol NtMapViewOfSection referenced in function mdbx_mmap
libmdbx_sys-5fd7a177ed6819e6.rlib(mdbx.o) : error LNK2019: unresolved external symbol NtUnmapViewOfSection referenced in function mdbx_mresize
libmdbx_sys-5fd7a177ed6819e6.rlib(mdbx.o) : error LNK2019: unresolved external symbol NtAllocateVirtualMemory referenced in function mdbx_mresize
libmdbx_sys-5fd7a177ed6819e6.rlib(mdbx.o) : error LNK2019: unresolved external symbol NtFreeVirtualMemory referenced in function mdbx_mresize
D:\a\ky\ky\target\x86_64-pc-windows-msvc\release\deps\ky.exe : fatal error LNK1120: 7 unresolved externals
error: aborting due to previous error
error: could not compile `ky`
To learn more, run the command again with --verbose.
Error: The process 'C:\Rust\.cargo\bin\cargo.exe' failed with exit code 101
- Related GHA: https://github.com/numToStr/ky/runs/2802130235
- Repo: https://github.com/numToStr/ky
I am still new to rust. So any help would be appreciated.
Thanks.
libmdbx's README#Windows: ...do not forget to add ntdll.lib
to linking.
@erthink Thanks for the quick insight. But I am also failing to understand how to link ntdll.lib
during compilation. Can you tell me how to do it?
Thanks.
libmdbx
itself provides properly building for all supported platforms, both by Make and by CMake.
So to fix the problem, it is enough to use native build ways, that the library provides.
Please ask @Kerollmops to fix this issue inside https://github.com/Kerollmops/mdbx-rs.
In addition, a very outdated version of libmdbx is used there now, and I strongly recommend updating it.
Thanks, @erthink for the explanation. Also created vorot93/libmdbx-rs#1.