Problems building Couchbase-lite-C w/ CMake on Windows

Hello,

I am facing problems building Couchbase-lite-C with CMake on Windows. I have also noticed that the LiteCore submodule used in the latest commit of Couchbase-lite-C does not compile on Windows if I try to compile it by itself. The latest commit of LiteCore (master), however, compiles with no problems on Windows.

This is the error message I am currently receiving:

17:07:59: Running steps for project CouchbaseLite_C…

17:08:00: Persisting CMake state…

17:08:17: Starting: “C:\Program Files\CMake\bin\cmake.exe” --build . --target all

Scanning dependencies of target CouchbaseLiteCStatic

[ 0%] Building CXX object CMakeFiles/CouchbaseLiteCStatic.dir/src/CBLBase.cc.obj

CBLBase.cc

[ 0%] Building CXX object CMakeFiles/CouchbaseLiteCStatic.dir/src/CBLBlob.cc.obj

CBLBlob.cc

[ 0%] Building CXX object CMakeFiles/CouchbaseLiteCStatic.dir/src/CBLDatabase.cc.obj

CBLDatabase.cc

[ 0%] Building CXX object CMakeFiles/CouchbaseLiteCStatic.dir/src/CBLDocument.cc.obj

CBLDocument.cc

[ 0%] Building CXX object CMakeFiles/CouchbaseLiteCStatic.dir/src/CBLLog.cc.obj

CBLLog.cc

[ 1%] Building CXX object CMakeFiles/CouchbaseLiteCStatic.dir/src/CBLQuery.cc.obj

CBLQuery.cc

[ 1%] Building CXX object CMakeFiles/CouchbaseLiteCStatic.dir/src/CBLReplicator.cc.obj

CBLReplicator.cc

c:\users\beave\desktop\couchbase-lite-c\src\CBLReplicator_Internal.hh(51): error C3861: ‘max’: identifier not found

c:\users\beave\desktop\couchbase-lite-c\src\CBLReplicator_Internal.hh(55): error C2397: conversion from ‘const uint64_t’ to ‘float’ requires a narrowing conversion

c:\users\beave\desktop\couchbase-lite-c\src\CBLReplicator_Internal.hh(52): warning C4244: ‘initializing’: conversion from ‘const uint64_t’ to ‘float’, possible loss of data

NMAKE : fatal error U1077: ‘C:\PROGRA~2\MICROS~1\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\HostX64\x64\cl.exe’ : return code ‘0x2’

Stop.

Any help will be appreciated. I had a similar issue about a week ago, which was quickly solved by @jens. Thanks in advance.

Sounds like a missing include … try adding #include <algorithm> at the top of the file, and let me know if it fixes the problem.

@jens,

Adding the suggested “include” did fix this problem, although a few others do come up afterwards. Eventually I was able to get past all of them and compile Couchbase-Lite-C successfully on Windows. If desired, I would be able to open a PR for the missing “includes” but not for all the errors I got. Otherwise, I could paste each error message here.
Thanks again for the help.

Yes, please do create a PR. Thanks!

@jens,

Thank you for the response. Since the issues I faced were not all in the Couchbase-Lite-C repository, I had to open several PRs/issues:

  1. PR for couchbase-lite-C
    https://github.com/couchbaselabs/couchbase-lite-C/pull/28

  2. Issue for couchbase-lite-C
    https://github.com/couchbaselabs/couchbase-lite-C/issues/29

  3. PR for sockpp
    https://github.com/couchbasedeps/sockpp/pull/1

  4. Issue for couchbase-lite-core
    https://github.com/couchbase/couchbase-lite-core/issues/890

Thanks again.

Thanks for the help! @borrrden has been working on fixing Windows and Linux compatibility, on a branch fix/ci_windows_etc.