Link static xapian to a share library

Olly Betts olly at survex.com
Fri Mar 25 20:27:46 GMT 2022


On Thu, Mar 24, 2022 at 02:39:50PM -0700, Yuan Fu wrote:
> I’m trying to link a static libxapian.a into my shared library, so
> that I can ship my library standalone.

Be aware that will likely cause problems if a program linking to your
library also links to libxapian directly or to another library which
uses libxapian internally - the issue is there will be two different
versions of libxapian loaded.  If libxapian is dynamically linked
then this problem is avoided.

> Undefined symbols for architecture x86_64:
>   "_deflate", referenced from:
[...]
> It seems that libxapian.a is missing some symbols? Did I compile it wrong?

Sounds like you haven't linked to zlib.  Dynamic libraries on modern
systems know which other libraries they depend on, but static libraries
are an ancient technology and don't - you need to specify the
dependencies by hand (or use xapian-config or pkg-config which paper
over this omission).

Cheers,
    Olly



More information about the Xapian-discuss mailing list