Closed clemera closed 5 years ago
It seems that the linker is failing due to missing Xapian symbols. Perhaps that's due to some ABI incompatibility between your compiler and the one that was used to build Xapian. If that's the case, you might try building Xapian from source. Or perhaps different combinations of the library and compiler, if Ubuntu has alternatives available.
After compiling xapian manually it still doesn't work. I don't want to invest more time on this, so I will retry it another time. Thanks!
I'm also having trouble compiling xapian on Ubuntu. The full error message is below. Any help would be greatly appreciated. Many thanks in advance!
~/notdeft/xapian$ make
g++ -o notdeft-xapian -std=c++11 -Wall pkg-config --cflags --libs tclap
xapian-config --cxxflags --libs
notdeft-xapian.cc
/usr/bin/ld: /tmp/ccu74YoX.o: in function doIndex(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >)::{lambda(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long> const&)#1}::operator()(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long> const&) const': notdeft-xapian.cc:(.text+0x18ab): undefined reference to
Xapian::Document::Document()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x18c4): undefined reference to Xapian::Document::set_data(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x18fc): undefined reference to
Xapian::Document::add_value(unsigned int, std::cxx11::basic_string<char, std::char_traitsXapian::Document::add_value(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x195b): undefined reference to
Xapian::TermGenerator::set_document(Xapian::Document const&)'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x1cbf): undefined reference to Xapian::TermGenerator::increase_termpos(unsigned int)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x1f0f): undefined reference to
Xapian::TermGenerator::increase_termpos(unsigned int)'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x2151): undefined reference to Xapian::TermGenerator::increase_termpos(unsigned int)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x2405): undefined reference to
Xapian::Document::~Document()'
/usr/bin/ld: /tmp/ccu74YoX.o: in function doIndex(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >)::{lambda(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long> const&)#2}::operator()(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long> const&) const': notdeft-xapian.cc:(.text+0x24d6): undefined reference to
Xapian::WritableDatabase::add_document(Xapian::Document const&)'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x24e2): undefined reference to Xapian::Document::~Document()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x2503): undefined reference to
Xapian::Document::~Document()'
/usr/bin/ld: /tmp/ccu74YoX.o: in function `doIndex(std::vector<std::Xapian::WritableDatabase::replace_document(unsigned int, Xapian::Document const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x25c5): undefined reference to
Xapian::Document::~Document()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x25e6): undefined reference to Xapian::Document::~Document()' /usr/bin/ld: /tmp/ccu74YoX.o: in function
doIndex(std::vector<std::cxx11::basic_string<char, std::char_traitsXapian::WritableDatabase::delete_document(unsigned int)' /usr/bin/ld: /tmp/ccu74YoX.o: in function
doIndex(std::vector<std::Xapian::TermGenerator::TermGenerator()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3868): undefined reference to
Xapian::Stem::Stem(std::Xapian::TermGenerator::set_stemmer(Xapian::Stem const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3a78): undefined reference to
Xapian::WritableDatabase::WritableDatabase(std::cxx11::basic_string<char, std::char_traitsXapian::WritableDatabase::begin_transaction(bool)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3cb3): undefined reference to
Xapian::Database::postlist_begin(std::Xapian::PostingIterator::operator*() const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3da1): undefined reference to
Xapian::Database::get_document(unsigned int) const'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x3dba): undefined reference to Xapian::Document::get_data[abi:cxx11]() const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3dd8): undefined reference to
Xapian::Document::get_value[abi:cxx11](unsigned int) const'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x3e65): undefined reference to Xapian::Document::~Document()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3e74): undefined reference to
Xapian::PostingIterator::operator++()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x43d5): undefined reference to Xapian::WritableDatabase::commit_transaction()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x4420): undefined reference to
Xapian::WritableDatabase::~WritableDatabase()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x4470): undefined reference to Xapian::Stem::~Stem()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x447f): undefined reference to
Xapian::TermGenerator::~TermGenerator()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x4ba1): undefined reference to Xapian::Document::~Document()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x4cdb): undefined reference to
Xapian::WritableDatabase::~WritableDatabase()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x4d4b): undefined reference to Xapian::Stem::~Stem()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x4d62): undefined reference to
Xapian::TermGenerator::~TermGenerator()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x4da0): undefined reference to Xapian::Error::get_description[abi:cxx11]() const' /usr/bin/ld: /tmp/ccu74YoX.o: in function
doSearch(std::vector<std::cxx11::basic_string<char, std::char_traitsXapian::Database::Database()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x5dbf): undefined reference to
Xapian::Database::Database(std::cxx11::basic_string<char, std::char_traitsXapian::Database::add_database(Xapian::Database const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x5dee): undefined reference to
Xapian::Database::~Database()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x5e52): undefined reference to Xapian::Enquire::Enquire(Xapian::Database const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x5e74): undefined reference to
Xapian::Enquire::set_sort_by_value(unsigned int, bool)'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x5e98): undefined reference to Xapian::Enquire::set_sort_by_value(unsigned int, bool)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x5ea7): undefined reference to
Xapian::QueryParser::QueryParser()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x5f1f): undefined reference to `Xapian::QueryParser::add_prefix(std::Xapian::QueryParser::add_prefix(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x6087): undefined reference to
Xapian::QueryParser::add_prefix(std::Xapian::QueryParser::add_prefix(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x619b): undefined reference to
Xapian::Stem::Stem(std::cxx11::basic_string<char, std::char_traitsXapian::Query::MatchAll' /usr/bin/ld: notdeft-xapian.cc:(.text+0x6200): undefined reference to
Xapian::QueryParser::set_stemmer(Xapian::Stem const&)'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x6219): undefined reference to Xapian::QueryParser::set_database(Xapian::Database const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x622d): undefined reference to
Xapian::QueryParser::set_stemming_strategy(Xapian::QueryParser::stem_strategy)'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x62c2): undefined reference to `Xapian::QueryParser::parse_query(std::Xapian::Query::get_description[abi:cxx11]() const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x6385): undefined reference to
Xapian::Enquire::set_query(Xapian::Query const&, unsigned int)'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x639d): undefined reference to Xapian::Database::get_doccount() const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x63e0): undefined reference to
Xapian::Enquire::get_mset(unsigned int, unsigned int, unsigned int, Xapian::RSet const, Xapian::MatchDecider const) const'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x6463): undefined reference to Xapian::MSetIterator::get_document() const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x647c): undefined reference to
Xapian::Document::get_data[abi:cxx11]() const'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x64c5): undefined reference to Xapian::Document::~Document()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x64f7): undefined reference to
Xapian::MSet::~MSet()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x6515): undefined reference to Xapian::Stem::~Stem()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x6524): undefined reference to
Xapian::QueryParser::~QueryParser()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x6533): undefined reference to Xapian::Enquire::~Enquire()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x656b): undefined reference to
Xapian::Database::~Database()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x6b65): undefined reference to Xapian::Database::~Database()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x6d71): undefined reference to
Xapian::Document::~Document()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x6d9f): undefined reference to Xapian::MSet::~MSet()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x6dc5): undefined reference to
Xapian::Stem::~Stem()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x6ddc): undefined reference to Xapian::QueryParser::~QueryParser()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x6df3): undefined reference to
Xapian::Enquire::~Enquire()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x6e21): undefined reference to Xapian::Database::~Database()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x6e5f): undefined reference to
Xapian::Error::get_description[abi:cxx11]() const'
/usr/bin/ld: /tmp/ccu74YoX.o: in function `doDump(std::vector<std::Xapian::Database::metadata_keys_begin(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x7428): undefined reference to
Xapian::TermIterator::operator[abi:cxx11]() const'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x7448): undefined reference to Xapian::Database::get_metadata(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x7537): undefined reference to
Xapian::Database::allterms_begin(std::__cxx11::basic_string<char, std::char_traitsXapian::Database::~Database()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x7890): undefined reference to
Xapian::Database::~Database()'
/usr/bin/ld: notdeft-xapian.cc:(.text+0x7917): undefined reference to Xapian::Error::get_description[abi:cxx11]() const' /usr/bin/ld: /tmp/ccu74YoX.o: in function
Xapian::PostingIterator::~PostingIterator()':
notdeft-xapian.cc:(.text._ZN6Xapian15PostingIteratorD2Ev[_ZN6Xapian15PostingIteratorD5Ev]+0x20): undefined reference to Xapian::PostingIterator::decref()' /usr/bin/ld: /tmp/ccu74YoX.o: in function
Xapian::TermIterator::~TermIterator()':
notdeft-xapian.cc:(.text._ZN6Xapian12TermIteratorD2Ev[_ZN6Xapian12TermIteratorD5Ev]+0x20): undefined reference to Xapian::TermIterator::decref()' /usr/bin/ld: /tmp/ccu74YoX.o: in function
Xapian::TermIterator::operator++abi:cxx11':
notdeft-xapian.cc:(.text._ZN6Xapian12TermIteratorppB5cxx11Ei[_ZN6Xapian12TermIteratorppB5cxx11Ei]+0x32): undefined reference to Xapian::TermIterator::operator*[abi:cxx11]() const' /usr/bin/ld: notdeft-xapian.cc:(.text._ZN6Xapian12TermIteratorppB5cxx11Ei[_ZN6Xapian12TermIteratorppB5cxx11Ei]+0x46): undefined reference to
Xapian::TermIterator::operator++()'
/usr/bin/ld: /tmp/ccu74YoX.o: in function Xapian::TermGenerator::index_text(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': notdeft-xapian.cc:(.text._ZN6Xapian13TermGenerator10index_textERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjS8_[_ZN6Xapian13TermGenerator10index_textERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjS8_]+0x4c): undefined reference to
Xapian::TermGenerator::index_text(Xapian::Utf8Iterator const&, unsigned int, std::cxx11::basic_string<char, std::char_traitsXapian::TermGenerator::index_text_without_positions(Xapian::Utf8Iterator const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: /tmp/ccu74YoX.o: in function
Xapian::MSetIterator::MSetIterator(Xapian::MSet const&, unsigned int)':
notdeft-xapian.cc:(.text._ZN6Xapian12MSetIteratorC2ERKNS_4MSetEj[_ZN6Xapian12MSetIteratorC5ERKNS_4MSetEj]+0x22): undefined reference to Xapian::MSet::MSet(Xapian::MSet const&)' /usr/bin/ld: /tmp/ccu74YoX.o: in function
Xapian::MSetIterator::~MSetIterator()':
notdeft-xapian.cc:(.text._ZN6Xapian12MSetIteratorD2Ev[_ZN6Xapian12MSetIteratorD5Ev]+0x14): undefined reference to Xapian::MSet::~MSet()' /usr/bin/ld: /tmp/ccu74YoX.o: in function
Xapian::MSet::begin() const':
notdeft-xapian.cc:(.text._ZNK6Xapian4MSet5beginEv[_ZNK6Xapian4MSet5beginEv]+0x18): undefined reference to `Xapian::MSet::size() const'
collect2: error: ld returned 1 exit status
make: *** [Makefile:10: notdeft-xapian] Error 1
It isn't just notdeft-xapian.cc. The ubuntu packaged Xapian examples also don't compile (similar errors, undefined references):
cd /tmp
sudo apt-get install xapian-examples
g++ -std=c++11 -Wall `xapian-config --cxxflags --libs` /usr/share/doc/xapian-examples/examples/simpleindex.cc
I also tested this on a docker image of Ubuntu 19.04 -- same problem. I also tried using different versions of Xapian (actually, these Debian versions: https://packages.debian.org/search?searchon=sourcenames&keywords=xapian-core). No luck. Same problem with 1.4.12-1, and 1.4.11-1. Version 1.2.19-1+deb8u1 was too old.
Looking at the missing symbols, a lot of them actually seem to be there.
nm -C -D /usr/lib/x86_64-linux-gnu/libxapian.so | less
Hallalujah! It works -- you must change the order of arguments in the Makefile. The call to xapian-config must be last. I'll send a pull request soon...
$(PROGRAM) : notdeft-xapian.cc
g++ -o $@ $< -std=c++11 -Wall `pkg-config --cflags --libs tclap` `xapian-config --cxxflags --libs`
Thank you, Warren, for finding a fix. I've merged your change.
Hi,
I have not much experience compiling C++ programs. I have installed the deps but compiliation fails (using g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0) with the following output:
Any ideas how to fix it?