From 765ff5dcb569abdc147d3cb13ef29bdedc842c8f Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sat, 30 Jun 2018 22:43:55 +0300 Subject: [PATCH] Fix crash on Windows with out_of_range exception & update docs --- CMakeSettings.json | 14 +++++++++++--- README.md | 27 +++++++++++++++++++++++++-- include/Cache.h | 6 +++--- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/CMakeSettings.json b/CMakeSettings.json index c90f665..cd32e37 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -11,9 +11,13 @@ "name": "CMAKE_TOOLCHAIN_FILE", "value": "${workspaceRoot}\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" // <-- change vcpkg location here }, + { + "name": "CMAKE_INSTALL_PREFIX", + "value": "${workspaceRoot}/.deps" + }, { "name": "Qt5_DIR", - "value": "C:\\Qt\\5.10.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here + "value": "C:\\Qt\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here } ] }, @@ -28,11 +32,15 @@ "name": "CMAKE_TOOLCHAIN_FILE", "value": "${workspaceRoot}\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" // <-- change vcpkg location here }, + { + "name": "CMAKE_INSTALL_PREFIX", + "value": "${workspaceRoot}/.deps" + }, { "name": "Qt5_DIR", - "value": "C:\\Qt\\5.10.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here + "value": "C:\\Qt\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here } ] }, ] -} \ No newline at end of file +} diff --git a/README.md b/README.md index f6d7706..4f4439b 100644 --- a/README.md +++ b/README.md @@ -133,14 +133,37 @@ brew install qt5 lmdb cmake llvm libsodium spdlog boost Make sure to install the `MSVC 2017 64-bit` toolset for at least Qt 5.9 (lower versions does not support VS2017). -3. Install lmdb and openssl with `vcpkg`. You can simply clone it into a subfolder +3. Install dependencies with `vcpkg`. You can simply clone it into a subfolder of the root nheko source directory. ```powershell git clone http:\\github.com\Microsoft\vcpkg cd vcpkg .\bootstrap-vcpkg.bat -.\vcpkg install --triplet x64-windows lmdb openssl +.\vcpkg install --triplet x64-windows \ + boost-asio \ + boost-beast \ + boost-iostreams \ + boost-random \ + boost-signals2 \ + boost-system \ + boost-thread \ + libsodium \ + lmdb \ + openssl \ + zlib +``` + +4. Install dependencies not managed by vcpkg. (libolm, libmtxclient, libmatrix_structs) + +Inside the project root run the following (replacing the path to vcpkg as necessary). + +```bash +cmake -G "Visual Studio 15 2017 Win64" -Hdeps -B.deps + -DCMAKE_TOOLCHAIN_FILE=C:/Users//vcpkg/scripts/buildsystems/vcpkg.cmake + -DUSE_BUNDLED_BOOST=OFF +cmake --build .deps --config Release +cmake --build .deps --config Debug ``` ### Building diff --git a/include/Cache.h b/include/Cache.h index 5d65c80..14f991e 100644 --- a/include/Cache.h +++ b/include/Cache.h @@ -48,11 +48,11 @@ struct SearchResult QString display_name; }; -inline int +static int numeric_key_comparison(const MDB_val *a, const MDB_val *b) { - auto lhs = std::stoul(std::string((char *)a->mv_data, a->mv_size)); - auto rhs = std::stoul(std::string((char *)b->mv_data, b->mv_size)); + auto lhs = std::stoull(std::string((char *)a->mv_data, a->mv_size)); + auto rhs = std::stoull(std::string((char *)b->mv_data, b->mv_size)); if (lhs < rhs) return 1;