Link static xapian to a share library

Yuan Fu casouri at gmail.com
Fri Mar 25 22:37:26 GMT 2022



> On Mar 25, 2022, at 1:27 PM, Olly Betts <olly at survex.com> wrote:
> 
> 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.

Thanks for the heads up!

> 
>> 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).

I see. Adding -lz solves it, thanks!

Yuan


More information about the Xapian-discuss mailing list