Couchbase-lite-C failed to build w/ CMake on MacOSX

Hello,

I am unable to build with CMake 3.14.5 on MacOSX. I followed the instructions and ran build.sh.

I have encountered 2 problems. I was able to solve the first but have found no solution for the second.

The first problem was a large sequence of errors starting with

In file included from /Users/zbh8jv/Desktop/couchbase-lite-C/src/CBLDatabase.cc:19:
In file included from /Users/zbh8jv/Desktop/couchbase-lite-C/src/CBLDatabase_Internal.hh:23:
In file included from /Users/zbh8jv/Desktop/couchbase-lite-C/src/Listener.hh:22:
/Users/zbh8jv/Desktop/couchbase-lite-C/vendor/couchbase-lite-core/LiteCore/Support/access_lock.hh:66:43: error: 
      no template named 'remove_reference_t' in namespace 'std'; did you
      mean 'remove_reference'?
        using LOCK = std::lock_guard<std::remove_reference_t<MUTEX>>;

which I was able to fix by setting CMAKE_CXX_STANDARD to 14.

The second problem generates the following error message

Scanning dependencies of target CouchbaseLiteCStatic
[  4%] Built target Support
[  7%] Built target BLIPStatic
[ 19%] Built target SQLite3_UnicodeSN
[ 24%] Built target LiteCoreWebSocket
[ 43%] Built target mbedcrypto
[ 60%] Built target FleeceStatic
[ 63%] Built target CouchbaseLiteCStatic
[ 65%] Built target mbedx509
[ 92%] Built target LiteCoreStatic
[ 95%] Built target mbedtls
Scanning dependencies of target CouchbaseLiteC
[ 97%] Building CXX object CMakeFiles/CouchbaseLiteC.dir/empty.cpp.o
[ 97%] Linking CXX shared library libCouchbaseLiteC.dylib
undef: __ZN8litecore3net10TLSContextC1ENS1_6role_tE
undef: __ZN8litecore3net10TLSContext12setRootCertsEN6fleece5sliceE
undef: __ZN8litecore3net10TLSContext11setIdentityEN6fleece5sliceES3_
undef: __ZN8litecore3net10TLSContext13allowOnlyCertEN6fleece5sliceE
undef: __ZNK12cbl_internal16ConflictResolver6resultEv
undef: __ZN12cbl_internal16ConflictResolverC1EP11CBLDatabasePFPK11CBLDocumentPvPKcS5_S5_ES6_RK15C4DocumentEnded
undef: _CBLDefaultConflictResolver
undef: __ZN8litecore3net10TLSContext11setIdentityEPNS_6crypto8IdentityE
undef: __ZN12cbl_internal16ConflictResolver8runAsyncENSt3__18functionIFvPS0_EEE
Undefined symbols for architecture x86_64:
  "litecore::net::TLSContext::TLSContext(litecore::net::TLSContext::role_t)", referenced from:
      litecore::websocket::BuiltInWebSocket::_connectLoop() in libLiteCoreWebSocket.a(BuiltInWebSocket.cc.o)
      litecore::net::TCPSocket::wrapTLS(fleece::slice) in libLiteCoreWebSocket.a(TCPSocket.cc.o)
  "litecore::net::TLSContext::setRootCerts(fleece::slice)", referenced from:
      litecore::websocket::BuiltInWebSocket::_connectLoop() in libLiteCoreWebSocket.a(BuiltInWebSocket.cc.o)
  "litecore::net::TLSContext::setIdentity(fleece::slice, fleece::slice)", referenced from:
      litecore::websocket::BuiltInWebSocket::configureClientCert(fleece::Dict) in libLiteCoreWebSocket.a(BuiltInWebSocket.cc.o)
  "litecore::net::TLSContext::allowOnlyCert(fleece::slice)", referenced from:
      litecore::websocket::BuiltInWebSocket::_connectLoop() in libLiteCoreWebSocket.a(BuiltInWebSocket.cc.o)
  "cbl_internal::ConflictResolver::result() const", referenced from:
      CBLReplicator::_conflictResolverFinished(cbl_internal::ConflictResolver*) in libCouchbaseLiteCStatic.a(CBLReplicator.cc.o)
  "cbl_internal::ConflictResolver::ConflictResolver(CBLDatabase*, CBLDocument const* (*)(void*, char const*, CBLDocument const*, CBLDocument const*), void*, C4DocumentEnded const&)", referenced from:
      CBLReplicator::_documentsEnded(bool, unsigned long, C4DocumentEnded const**) in libCouchbaseLiteCStatic.a(CBLReplicator.cc.o)
  "_CBLDefaultConflictResolver", referenced from:
     -exported_symbol[s_list] command line option
  "litecore::net::TLSContext::setIdentity(litecore::crypto::Identity*)", referenced from:
      litecore::websocket::BuiltInWebSocket::configureClientCert(fleece::Dict) in libLiteCoreWebSocket.a(BuiltInWebSocket.cc.o)
  "cbl_internal::ConflictResolver::runAsync(std::__1::function<void (cbl_internal::ConflictResolver*)>)", referenced from:
      CBLReplicator::_documentsEnded(bool, unsigned long, C4DocumentEnded const**) in libCouchbaseLiteCStatic.a(CBLReplicator.cc.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libCouchbaseLiteC.dylib] Error 1
make[1]: *** [CMakeFiles/CouchbaseLiteC.dir/all] Error 2
make: *** [all] Error 2

I am aware Xcode can be used (and I was able to), but for my purposes I need to build it through Cmake. Any help will be appreciated. Further info:

CMake version 3.14.5
Mac OSX Mojave 10.14.6
AppleClang 10.0.1.10010046

Thanks in advance

Oops, looks like I haven’t kept the CMake files up to date. I’ll fix them.

…fixed! Thanks for letting me know about the problem.

1 Like