Build fail - Couchbase Lite C on Linux/Debian 11 (Bullseye)

I want to compile the latest version of couchbase lite c (commit 1f05a58ea0e8673ffcadb4e11d11b9c3281c650a Sun Nov 10 16:15:44 2019 -0800) but the build fail. This is was I tried to get it done.

First stumbling block:
/root/couchbase-lite-C/vendor/couchbase-lite-core/Crypto/Certificate.cc:130:9: error: ‘reverse’ was not declared in this scope; did you mean ‘reserve’?
130 | reverse(begin(), end()); // subject_alt_names list is in reverse order!

Solution: Open /root/couchbase-lite-C/vendor/couchbase-lite-core/Crypto/Certificate.cc and commented line 130 out. My target is to compile the project. After then I would like to check how I can solve the problem with the reverse function.

Second stumbling block:
/root/couchbase-lite-C/vendor/couchbase-lite-core/vendor/sockpp/include/sockpp/mbedtls_context.h:94:29: error: ‘function’ in namespace ‘std’ does not name a template type
94 | using Logger = std::function<void(int level, const char *filename, int line, const char *message)>;
| ^~~~~~~~
/root/couchbase-lite-C/vendor/couchbase-lite-core/vendor/sockpp/include/sockpp/mbedtls_context.h:52:1: note: ‘std::function’ is defined in header ‘’; did you forget to '#include '?

Solution: Add #include in line 54 in file /root/couchbase-lite-C/vendor/couchbase-lite-core/vendor/sockpp/include/sockpp/mbedtls_context.h line

With these two hacks I come nearly to the end, but the build breaks on:
[100%] Linking CXX executable CBL_C_Tests
/usr/bin/ld: …/libCouchbaseLiteC.so: undefined reference to ucol_open_63' /usr/bin/ld: ../libCouchbaseLiteC.so: undefined reference to ucasemap_close_63’
/usr/bin/ld: …/libCouchbaseLiteC.so: undefined reference to ucol_strcollUTF8_63' /usr/bin/ld: ../libCouchbaseLiteC.so: undefined reference to ucol_setAttribute_63’
/usr/bin/ld: …/libCouchbaseLiteC.so: undefined reference to ucol_close_63' /usr/bin/ld: ../libCouchbaseLiteC.so: undefined reference to ucasemap_open_63’
/usr/bin/ld: …/libCouchbaseLiteC.so: undefined reference to ucasemap_utf8ToUpper_63' /usr/bin/ld: ../libCouchbaseLiteC.so: undefined reference to ucasemap_utf8ToLower_63’
collect2: error: ld returned 1 exit status
make[2]: *** [test/CMakeFiles/CBL_C_Tests.dir/build.make:191: test/CBL_C_Tests] Error 1
make[1]: *** [CMakeFiles/Makefile2:5592: test/CMakeFiles/CBL_C_Tests.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

From here on I am a bit baffled and need your help.
I use:

  • gcc/g++ 9.2.1
  • cmake 3.15.4

If you need more details to help me out, please let me know.

P.S. Did anyone build the project successfully on linux (amd64)? If yes, please let me know which distro/version you use.

Development is done with Clang, and we don’t have CI set up yet, so there are sometimes regressions when building with GCC. The most common problems are missing #includes, which is what you’ve run into.

/root/couchbase-lite-C/vendor/couchbase-lite-core/Crypto/Certificate.cc:130:9: error: ‘reverse’ was not declared in this scope; did you mean ‘reserve’?

Add #include <algorithm> to the file.

(We will be making these fixes soon, but editing the files yourself will help you get unblocked.)
/root/couchbase-lite-C/vendor/couchbase-lite-core/vendor/sockpp/include/sockpp/mbedtls_context.h:94:29: error: ‘function’ in namespace ‘std’ does not name a template type

Add #include <functional>

We will make these fixes soon, but editing the file yourself will help you get unblocked.

Actually those issues have already been fixed in newer commits.

If you’re building for Linux, I suggest checking out the branch fix/ci_windows_etc which is where @borrrden is fixing cross-platform issues.