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

Adding Windows Support #475

Closed
Netzeband opened this issue Jun 1, 2017 · 2 comments
Closed

Adding Windows Support #475

Netzeband opened this issue Jun 1, 2017 · 2 comments

Comments

@Netzeband
Copy link

Unfortunately the developers of this library did not spend any amount on effort to make this library compilable on Windows. Even the build-system, it not portable.

I updated the windows port from https://github.com/bureau14/leveldb/blob/master, which was based on levelDB 1.18 to version 1.20. The following patches are necessary:

1.) The CMakeList file from https://github.com/bureau14/leveldb/blob/master which works with 1.18
2.) Some changes to this file to make it compatible with 1.20
3.) Several files, which are necessary for windows (also taken form https://github.com/bureau14/leveldb/blob/master) combined with some adoptions to make everything compatible to 1.20.
4.) Some adoptions to the tests. Windows don't like to delete a file, which is currently in use by the same process.

You can find the patches in the attached ZIP.
patches.zip

Furthermore this is a appveyor.yml file, which compiles levelDB 1.20 on AppVeyor CI Build system for Windows 64bit, 32bit as Release and Debug build:

image: Visual Studio 2015
version: 1.0.{build}

environment:
  matrix:
    - PLATFORM: x86
      BUILDTYPE: Debug
    - PLATFORM: x64
      BUILDTYPE: Debug	
    - PLATFORM: x86
      BUILDTYPE: Release
    - PLATFORM: x64
      BUILDTYPE: Release	

clone_folder: c:\projects\leveldb
init:
- if "%PLATFORM%"=="x64" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
- if "%PLATFORM%"=="x86" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
build_script:
- cmd: >-
    cd c:\projects\leveldb

    mkdir build

    cd build

    cmake --version

    cmake -G "NMake Makefiles" .. -DCMAKE_INSTALL_PREFIX=../../install/appveyor -DCMAKE_BUILD_TYPE=%BUILDTYPE% -DBOOST_ROOT=C:\Libraries\boost_1_62_0

    nmake install
test_script:
- cmd: nmake test

I have not tested the CMake-build system on linux so far. But I will do it within the next weeks. If I see issues, I will release some additional patches.

By the way: Even on *nix systems CMake is a better choice as build system than pure Makefiles. It solves many dependencies by itself and on top of it will give you cross-compile possibility for free. Yeah I know, it is hard to use something different, when you are used to pure Makefiles. But give it a try.

@Netzeband Netzeband mentioned this issue Jun 1, 2017
@Netzeband
Copy link
Author

Today I notices, that the current windows build with the above patches will not enable SNAPPY for levelDB. If you are working with databases which use SNAPPY, this can be an issue.

Thus I created 4 more patch files. All patch files are contained in the following ZIP.
patches.zip

The following files are relevant (in addition to the files, described above):
5.) The library files are now installed during installation step.
6.) All Header files are installed during installation step.
7.) Enable SNAPPY support for windows.
8.) Check environment variable SNAPPY_ROOT to set root dir automatically.

For the Snappy support I used as base the file "FindSnappy.cmake" from repository https://github.com/lemire/FastPFor
This files was published under Apache license. I adapted the file to work together with the precompiles windows version of snappy which can be downloaded from here: https://snappy.machinezoo.com/

@cmumford
Copy link
Contributor

Official support for Windows is probably the most requested enhancement. We are currently working on CMake support with continuous integration via AppVeyor. Using issue #466 to track this work.

maochongxin pushed a commit to maochongxin/leveldb that referenced this issue Jul 21, 2022
When stopping a timer, the current time is subtracted
from the start time. However, when the times are identical,
or sufficiently close together, the subtraction can result
in a negative number.

For some reason MinGW is the only platform where this problem
manifests. I suspect it's due to MinGW specific behavior in either
the CPU timing code, floating point model, or printf formatting.

Either way, the fix for MinGW should be correct across all platforms.
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

2 participants