Skip to content
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

mdbx: Unable to compile on windows #107

Closed
numToStr opened this issue Jun 11, 2021 · 4 comments
Closed

mdbx: Unable to compile on windows #107

numToStr opened this issue Jun 11, 2021 · 4 comments

Comments

@numToStr
Copy link

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

I am still new to rust. So any help would be appreciated.

Thanks.

@erthink
Copy link

erthink commented Jun 11, 2021

libmdbx's README#Windows: ...do not forget to add ntdll.lib to linking.

@numToStr
Copy link
Author

@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.

numToStr added a commit to numToStr/ky that referenced this issue Jun 11, 2021
Currently, windows is not working because of mdbx is failing to compile
on windows and I don't fully understand how to fix, but there is a fix.
Ref: meilisearch/heed#107 (comment)

And crate publish will fail because clap-rs is used from source
@erthink
Copy link

erthink commented Jun 11, 2021

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.

@numToStr
Copy link
Author

Thanks, @erthink for the explanation. Also created vorot93/libmdbx-rs#1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants