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.

Thank you very much @jens and @borrrden for the help.

I am attempting to clone and test the fixes made on the “fix/ci_windows_etc” branch but I have not been able to properly download the code. I think this may be due to some issue on the submodule commit chain.

The command I would normally use in this scenario, which is

git clone -b fix/ci_windows_etc GitHub - couchbase/couchbase-lite-C: C language bindings for the Couchbase Lite embedded NoSQL database engine --recurse-submodules

fails with the error

error: Server does not allow request for unadvertised object fecf319cbf49387e7813965d68531ac0aa5637b0

Fetched in submodule path ‘vendor/couchbase-lite-core’, but it did not contain fecf319cbf49387e7813965d68531ac0aa5637b0. Direct fetching of that commit failed.

Thanks again and keep up the great work.

There have been multiple rebases of the downstream core branch. For the meantime, just keep tracking the fix/cbl_c_windows branch of core instead of using the submodule.

Got it to work now. I didn’t know LiteCore should be at branch fix/cbl_c_windows. All seems to be working fine, no problems on my end. Thanks again.

I don’t expect that anyone knows that but me. I am trying to get LiteCore to work before I start up some PR validation / CI for the C library so I am basically ignoring the submodule at the moment.