Problem compiling with new iOS CouchbaseLite v1.3

Existing project previously building fine with Couchbase lite v1.2.1, I replaced the CouchbaseLite and CouchbaseLiteListener frameworks for the new 1.3.0 version, and upon compiling was getting about 26 errors related to undefined symbols similar to:

Undefined symbols for architecture x86_64:
“std::__1::__vector_base_common::__throw_length_error() const”, referenced from:
std::__1::vector<couchbase::differ::Change, std::__1::allocatorcouchbase::differ::Change >::allocate(unsigned long) in CouchbaseLite(Differ.o)
void std::__1::vector<couchbase::differ::Change, std::__1::allocatorcouchbase::differ::Change
… continues on for many lines…

Seeing that these related to C++, I thought perhaps there’s a new not-yet-documented requirement to link to libc++, so I added that, and those errors were replaced with these:

duplicate symbol _AllLogDomains in:
/<…>/Frameworks/iOS/CouchbaseLite.framework/CouchbaseLite(MYLogging.o)
duplicate symbol _AlwaysLog in:
/<…>/Frameworks/iOS/CouchbaseLite.framework/CouchbaseLite(MYLogging.o)
duplicate symbol _EnableLog in:
/<…>/Frameworks/iOS/CouchbaseLite.framework/CouchbaseLite(MYLogging.o)
duplicate symbol _EnableLogTo in:
/<…>/Frameworks/iOS/CouchbaseLite.framework/CouchbaseLite(MYLogging.o)
duplicate symbol _MYDefault_LogDomain in:
/<…>/Frameworks/iOS/CouchbaseLite.framework/CouchbaseLite(MYLogging.o)
duplicate symbol _MYLogTo in:
/<…>/Frameworks/iOS/CouchbaseLite.framework/CouchbaseLite(MYLogging.o)
duplicate symbol _MYLoggingCallback in:
/<…>/Frameworks/iOS/CouchbaseLite.framework/CouchbaseLite(MYLogging.o)
duplicate symbol _MYWarn in:
/<…>/Frameworks/iOS/CouchbaseLite.framework/CouchbaseLite(MYLogging.o)
duplicate symbol __WillLogTo in:
/<…>/Frameworks/iOS/CouchbaseLite.framework/CouchbaseLite(MYLogging.o)
duplicate symbol _gMYLogDomainList in:
/<…>/Frameworks/iOS/CouchbaseLite.framework/CouchbaseLite(MYLogging.o)
duplicate symbol _gMYWarnRaisesException in:
/<…>/Frameworks/iOS/CouchbaseLite.framework/CouchbaseLite(MYLogging.o)
ld: 11 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

So, are there new linking/building requirements for iOS CB Lite v1.3?
Thanks

It kind of looks like you’re linking with two copies of Couchbase Lite.

Ah, I discovered the cause. I had -all_load under the “Other Linker Flags” in the project settings. I believe earlier versions of CBL required this, and while v1.2.1 didn’t care if it was there, apparently in v1.3.0 it will cause an this error if included…
Thanks

1 Like

I removed -all_load under “Other Linker Flags” and got my project to compile. However, syncing has stopped working. If I use CouchbaseLite 1.2 with -all_load, everything works fine. Any ideas as to what could be the issue? Thanks!

I don’t know what causes this. It hasn’t happened in our testing or with our sample apps, and only a couple of people have reported link errors with 1.3. If someone is willing to send me their project folder, or let me check it out from Github, I can take a look. (You can email a zip file or a link to jens at couchbase dot com.)

Hi Jens. I sent you an email with a zip file. Please let me know if there’s anything you need to diagnose/fix the issue. Thanks!

I just sent a reply. I can’t find anything in the project that actually links with Couchbase Lite. The app target links with a ton of frameworks, but none of them are ours. When I tried to build it, it failed because the linker couldn’t find one of the frameworks (no idea why.)

Turns out there are two copies of MYLogging.o in the iOS static-library framework. This doesn’t cause any problems unless your app target uses the linker flag -all_load; then you get duplicate symbol errors.

I filed a Github issue, and checked in a fix on the master branch.

1 Like