Hi,
I?m trying to link a static libxapian.a into my shared library, so that I can
ship my library standalone. I compiled xapian with
./configure --disable-shared
make CPPFLAGS=-fPIC
And tried to link it to my shared library by
c++ mylib.o -o mylib.dylib -shared -fPIC -I/opt/local/include -Wl,-force_load
/opt/local/lib/libxapian.a
-force_load is Mac?s equivalent to --whole-archive, only that it doesn?t need a
--no-whole-archive.
I?m getting symbol not found error like this:
Undefined symbols for architecture x86_64:
"_deflate", referenced from:
ChertTable::add(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >
const&, std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >, bool) in libxapian.a(chert_table.o)
CompressionStream::compress(char const*, unsigned long*) in
libxapian.a(compression_stream.o)
(maybe you meant: ChertTable::lazy_alloc_deflate_zstream() const,
CompressionStream::lazy_alloc_deflate_zstream() )
"_deflateEnd", referenced from:
ChertTable::~ChertTable() in libxapian.a(chert_table.o)
CompressionStream::~CompressionStream() in
libxapian.a(compression_stream.o)
"_deflateInit2_", referenced from:
ChertTable::lazy_alloc_deflate_zstream() const in
libxapian.a(chert_table.o)
CompressionStream::lazy_alloc_deflate_zstream() in
libxapian.a(compression_stream.o)
"_deflateReset", referenced from:
ChertTable::lazy_alloc_deflate_zstream() const in
libxapian.a(chert_table.o)
CompressionStream::lazy_alloc_deflate_zstream() in
libxapian.a(compression_stream.o)
"_inflate", referenced from:
ChertTable::read_tag(Cursor*, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >*, bool)
const in libxapian.a(chert_table.o)
CompressionStream::decompress_chunk(char const*, int,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >&) in libxapian.a(compression_stream.o)
(maybe you meant: CompressionStream::lazy_alloc_inflate_zstream(),
ChertTable::lazy_alloc_inflate_zstream() const )
"_inflateEnd", referenced from:
ChertTable::~ChertTable() in libxapian.a(chert_table.o)
CompressionStream::~CompressionStream() in
libxapian.a(compression_stream.o)
"_inflateInit2_", referenced from:
ChertTable::lazy_alloc_inflate_zstream() const in
libxapian.a(chert_table.o)
CompressionStream::lazy_alloc_inflate_zstream() in
libxapian.a(compression_stream.o)
"_inflateReset", referenced from:
ChertTable::lazy_alloc_inflate_zstream() const in
libxapian.a(chert_table.o)
CompressionStream::lazy_alloc_inflate_zstream() in
libxapian.a(compression_stream.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It seems that libxapian.a is missing some symbols? Did I compile it wrong?
Thanks,
Yuan