hasu / notdeft

NotDeft note manager for Emacs
https://tero.hasu.is/notdeft/
170 stars 14 forks source link

Failing to compile notdeft-xapian using [g++ Ubuntu 7.3.0-27ubuntu1~18.04)] #4

Closed clemera closed 5 years ago

clemera commented 5 years ago

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:

g++ -o notdeft-xapian -std=c++11 -Wall `pkg-config --cflags --libs tclap` `xapian-config --cxxflags --libs` notdeft-xapian.cc
/tmp/cclA1HIj.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+0x18b7): undefined reference to `Xapian::Document::Document()'
notdeft-xapian.cc:(.text+0x18d0): undefined reference to `Xapian::Document::set_data(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
notdeft-xapian.cc:(.text+0x1908): undefined reference to `Xapian::Document::add_value(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
notdeft-xapian.cc:(.text+0x194b): undefined reference to `Xapian::Document::add_value(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
notdeft-xapian.cc:(.text+0x1967): undefined reference to `Xapian::TermGenerator::set_document(Xapian::Document const&)'
notdeft-xapian.cc:(.text+0x1ccb): undefined reference to `Xapian::TermGenerator::increase_termpos(unsigned int)'
notdeft-xapian.cc:(.text+0x1f1b): undefined reference to `Xapian::TermGenerator::increase_termpos(unsigned int)'
notdeft-xapian.cc:(.text+0x215d): undefined reference to `Xapian::TermGenerator::increase_termpos(unsigned int)'
notdeft-xapian.cc:(.text+0x2411): undefined reference to `Xapian::Document::~Document()'
/tmp/cclA1HIj.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+0x24e2): undefined reference to `Xapian::WritableDatabase::add_document(Xapian::Document const&)'
notdeft-xapian.cc:(.text+0x24ee): undefined reference to `Xapian::Document::~Document()'
notdeft-xapian.cc:(.text+0x250f): undefined reference to `Xapian::Document::~Document()'
/tmp/cclA1HIj.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&, unsigned int)#3}::operator()(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long> const&, unsigned int) const':
notdeft-xapian.cc:(.text+0x25c5): undefined reference to `Xapian::WritableDatabase::replace_document(unsigned int, Xapian::Document const&)'
notdeft-xapian.cc:(.text+0x25d1): undefined reference to `Xapian::Document::~Document()'
notdeft-xapian.cc:(.text+0x25f2): undefined reference to `Xapian::Document::~Document()'
/tmp/cclA1HIj.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&)#4}::operator()(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long> const&) const':
notdeft-xapian.cc:(.text+0x2693): undefined reference to `Xapian::WritableDatabase::delete_document(unsigned int)'
/tmp/cclA1HIj.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> > > >)':
notdeft-xapian.cc:(.text+0x3850): undefined reference to `Xapian::TermGenerator::TermGenerator()'
notdeft-xapian.cc:(.text+0x3874): undefined reference to `Xapian::Stem::Stem(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
notdeft-xapian.cc:(.text+0x388d): undefined reference to `Xapian::TermGenerator::set_stemmer(Xapian::Stem const&)'
notdeft-xapian.cc:(.text+0x3a84): undefined reference to `Xapian::WritableDatabase::WritableDatabase(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int)'
notdeft-xapian.cc:(.text+0x3c73): undefined reference to `Xapian::WritableDatabase::begin_transaction(bool)'
notdeft-xapian.cc:(.text+0x3cbf): undefined reference to `Xapian::Database::postlist_begin(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
notdeft-xapian.cc:(.text+0x3d88): undefined reference to `Xapian::PostingIterator::operator*() const'
notdeft-xapian.cc:(.text+0x3dad): undefined reference to `Xapian::Database::get_document(unsigned int) const'
notdeft-xapian.cc:(.text+0x3dc6): undefined reference to `Xapian::Document::get_data[abi:cxx11]() const'
notdeft-xapian.cc:(.text+0x3de4): undefined reference to `Xapian::Document::get_value[abi:cxx11](unsigned int) const'
notdeft-xapian.cc:(.text+0x3e71): undefined reference to `Xapian::Document::~Document()'
notdeft-xapian.cc:(.text+0x3e80): undefined reference to `Xapian::PostingIterator::operator++()'
notdeft-xapian.cc:(.text+0x43e1): undefined reference to `Xapian::WritableDatabase::commit_transaction()'
notdeft-xapian.cc:(.text+0x442c): undefined reference to `Xapian::WritableDatabase::~WritableDatabase()'
notdeft-xapian.cc:(.text+0x447c): undefined reference to `Xapian::Stem::~Stem()'
notdeft-xapian.cc:(.text+0x448b): undefined reference to `Xapian::TermGenerator::~TermGenerator()'
notdeft-xapian.cc:(.text+0x4bad): undefined reference to `Xapian::Document::~Document()'
notdeft-xapian.cc:(.text+0x4ce7): undefined reference to `Xapian::WritableDatabase::~WritableDatabase()'
notdeft-xapian.cc:(.text+0x4d57): undefined reference to `Xapian::Stem::~Stem()'
notdeft-xapian.cc:(.text+0x4d6e): undefined reference to `Xapian::TermGenerator::~TermGenerator()'
notdeft-xapian.cc:(.text+0x4dac): undefined reference to `Xapian::Error::get_description[abi:cxx11]() const'
/tmp/cclA1HIj.o: In function `doSearch(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> > > >)':
notdeft-xapian.cc:(.text+0x5c70): undefined reference to `Xapian::Database::Database()'
notdeft-xapian.cc:(.text+0x5dcb): undefined reference to `Xapian::Database::Database(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
notdeft-xapian.cc:(.text+0x5de4): undefined reference to `Xapian::Database::add_database(Xapian::Database const&)'
notdeft-xapian.cc:(.text+0x5dfa): undefined reference to `Xapian::Database::~Database()'
notdeft-xapian.cc:(.text+0x5e5e): undefined reference to `Xapian::Enquire::Enquire(Xapian::Database const&)'
notdeft-xapian.cc:(.text+0x5e80): undefined reference to `Xapian::Enquire::set_sort_by_value(unsigned int, bool)'
notdeft-xapian.cc:(.text+0x5ea4): undefined reference to `Xapian::Enquire::set_sort_by_value(unsigned int, bool)'
notdeft-xapian.cc:(.text+0x5eb3): undefined reference to `Xapian::QueryParser::QueryParser()'
notdeft-xapian.cc:(.text+0x5f2b): undefined reference to `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&)'
notdeft-xapian.cc:(.text+0x5fdf): undefined reference to `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&)'
notdeft-xapian.cc:(.text+0x6093): undefined reference to `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&)'
notdeft-xapian.cc:(.text+0x6147): undefined reference to `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&)'
notdeft-xapian.cc:(.text+0x61a7): undefined reference to `Xapian::Stem::Stem(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
notdeft-xapian.cc:(.text+0x61e6): undefined reference to `Xapian::Query::MatchAll'
notdeft-xapian.cc:(.text+0x620c): undefined reference to `Xapian::QueryParser::set_stemmer(Xapian::Stem const&)'
notdeft-xapian.cc:(.text+0x6225): undefined reference to `Xapian::QueryParser::set_database(Xapian::Database const&)'
notdeft-xapian.cc:(.text+0x6239): undefined reference to `Xapian::QueryParser::set_stemming_strategy(Xapian::QueryParser::stem_strategy)'
notdeft-xapian.cc:(.text+0x62ce): undefined reference to `Xapian::QueryParser::parse_query(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+0x633d): undefined reference to `Xapian::Query::get_description[abi:cxx11]() const'
notdeft-xapian.cc:(.text+0x6391): undefined reference to `Xapian::Enquire::set_query(Xapian::Query const&, unsigned int)'
notdeft-xapian.cc:(.text+0x63a9): undefined reference to `Xapian::Database::get_doccount() const'
notdeft-xapian.cc:(.text+0x63ec): undefined reference to `Xapian::Enquire::get_mset(unsigned int, unsigned int, unsigned int, Xapian::RSet const*, Xapian::MatchDecider const*) const'
notdeft-xapian.cc:(.text+0x646f): undefined reference to `Xapian::MSetIterator::get_document() const'
notdeft-xapian.cc:(.text+0x6488): undefined reference to `Xapian::Document::get_data[abi:cxx11]() const'
notdeft-xapian.cc:(.text+0x64d1): undefined reference to `Xapian::Document::~Document()'
notdeft-xapian.cc:(.text+0x6503): undefined reference to `Xapian::MSet::~MSet()'
notdeft-xapian.cc:(.text+0x6521): undefined reference to `Xapian::Stem::~Stem()'
notdeft-xapian.cc:(.text+0x6530): undefined reference to `Xapian::QueryParser::~QueryParser()'
notdeft-xapian.cc:(.text+0x653f): undefined reference to `Xapian::Enquire::~Enquire()'
notdeft-xapian.cc:(.text+0x6578): undefined reference to `Xapian::Database::~Database()'
notdeft-xapian.cc:(.text+0x6b73): undefined reference to `Xapian::Database::~Database()'
notdeft-xapian.cc:(.text+0x6d7f): undefined reference to `Xapian::Document::~Document()'
notdeft-xapian.cc:(.text+0x6dad): undefined reference to `Xapian::MSet::~MSet()'
notdeft-xapian.cc:(.text+0x6dd3): undefined reference to `Xapian::Stem::~Stem()'
notdeft-xapian.cc:(.text+0x6dea): undefined reference to `Xapian::QueryParser::~QueryParser()'
notdeft-xapian.cc:(.text+0x6e01): undefined reference to `Xapian::Enquire::~Enquire()'
notdeft-xapian.cc:(.text+0x6e2f): undefined reference to `Xapian::Database::~Database()'
notdeft-xapian.cc:(.text+0x6e6d): undefined reference to `Xapian::Error::get_description[abi:cxx11]() const'
/tmp/cclA1HIj.o: In function `doDump(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> > > >)':
notdeft-xapian.cc:(.text+0x736f): undefined reference to `Xapian::Database::Database(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
notdeft-xapian.cc:(.text+0x739e): undefined reference to `Xapian::Database::metadata_keys_begin(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
notdeft-xapian.cc:(.text+0x7436): undefined reference to `Xapian::TermIterator::operator*[abi:cxx11]() const'
notdeft-xapian.cc:(.text+0x7456): undefined reference to `Xapian::Database::get_metadata(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
notdeft-xapian.cc:(.text+0x7545): undefined reference to `Xapian::Database::allterms_begin(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
notdeft-xapian.cc:(.text+0x75f3): undefined reference to `Xapian::TermIterator::operator*[abi:cxx11]() const'
notdeft-xapian.cc:(.text+0x7679): undefined reference to `Xapian::Database::~Database()'
notdeft-xapian.cc:(.text+0x789e): undefined reference to `Xapian::Database::~Database()'
notdeft-xapian.cc:(.text+0x7925): undefined reference to `Xapian::Error::get_description[abi:cxx11]() const'
/tmp/cclA1HIj.o: In function `Xapian::PostingIterator::~PostingIterator()':
notdeft-xapian.cc:(.text._ZN6Xapian15PostingIteratorD2Ev[_ZN6Xapian15PostingIteratorD5Ev]+0x20): undefined reference to `Xapian::PostingIterator::decref()'
/tmp/cclA1HIj.o: In function `Xapian::TermIterator::~TermIterator()':
notdeft-xapian.cc:(.text._ZN6Xapian12TermIteratorD2Ev[_ZN6Xapian12TermIteratorD5Ev]+0x20): undefined reference to `Xapian::TermIterator::decref()'
/tmp/cclA1HIj.o: In function `Xapian::TermIterator::operator++[abi:cxx11](int)':
notdeft-xapian.cc:(.text._ZN6Xapian12TermIteratorppB5cxx11Ei[_ZN6Xapian12TermIteratorppB5cxx11Ei]+0x32): undefined reference to `Xapian::TermIterator::operator*[abi:cxx11]() const'
notdeft-xapian.cc:(.text._ZN6Xapian12TermIteratorppB5cxx11Ei[_ZN6Xapian12TermIteratorppB5cxx11Ei]+0x46): undefined reference to `Xapian::TermIterator::operator++()'
/tmp/cclA1HIj.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_traits<char>, std::allocator<char> > const&)'
/tmp/cclA1HIj.o: In function `Xapian::TermGenerator::index_text_without_positions(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._ZN6Xapian13TermGenerator28index_text_without_positionsERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjS8_[_ZN6Xapian13TermGenerator28index_text_without_positionsERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjS8_]+0x4c): undefined reference to `Xapian::TermGenerator::index_text_without_positions(Xapian::Utf8Iterator const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/cclA1HIj.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&)'
/tmp/cclA1HIj.o: In function `Xapian::MSetIterator::~MSetIterator()':
notdeft-xapian.cc:(.text._ZN6Xapian12MSetIteratorD2Ev[_ZN6Xapian12MSetIteratorD5Ev]+0x14): undefined reference to `Xapian::MSet::~MSet()'
/tmp/cclA1HIj.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
Makefile:10: recipe for target 'notdeft-xapian' failed
make: *** [notdeft-xapian] Error 1

Any ideas how to fix it?

hasu commented 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.

clemera commented 5 years ago

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!

anthrolisp commented 5 years ago

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 toXapian::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 toXapian::Document::add_value(unsigned int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x193f): undefined reference to Xapian::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 toXapian::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 toXapian::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 toXapian::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 toXapian::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 toXapian::Document::~Document()' /usr/bin/ld: /tmp/ccu74YoX.o: in function `doIndex(std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::cxx11::basic_string<char, std::char_traits, std::allocator > > >)::{lambda(std::pair<std::cxx11::basic_string<char, std::char_traits, std::allocator >, long> const&, unsigned int)#3}::operator()(std::pair<std::cxx11::basic_string<char, std::char_traits, std::allocator >, long> const&, unsigned int) const': notdeft-xapian.cc:(.text+0x25b9): undefined reference to Xapian::WritableDatabase::replace_document(unsigned int, Xapian::Document const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x25c5): undefined reference toXapian::Document::~Document()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x25e6): undefined reference to Xapian::Document::~Document()' /usr/bin/ld: /tmp/ccu74YoX.o: in functiondoIndex(std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::cxx11::basic_string<char, std::char_traits, std::allocator > > >)::{lambda(std::pair<std::cxx11::basic_string<char, std::char_traits, std::allocator >, long> const&)#4}::operator()(std::pair<std::cxx11::basic_string<char, std::char_traits, std::allocator >, long> const&) const': notdeft-xapian.cc:(.text+0x2687): undefined reference to Xapian::WritableDatabase::delete_document(unsigned int)' /usr/bin/ld: /tmp/ccu74YoX.o: in functiondoIndex(std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::cxx11::basic_string<char, std::char_traits, std::allocator > > >)': notdeft-xapian.cc:(.text+0x3844): undefined reference to Xapian::TermGenerator::TermGenerator()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3868): undefined reference toXapian::Stem::Stem(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3881): undefined reference to Xapian::TermGenerator::set_stemmer(Xapian::Stem const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3a78): undefined reference toXapian::WritableDatabase::WritableDatabase(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int, int)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3c67): undefined reference to Xapian::WritableDatabase::begin_transaction(bool)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3cb3): undefined reference toXapian::Database::postlist_begin(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&) const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3d7c): undefined reference to Xapian::PostingIterator::operator*() const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x3da1): undefined reference toXapian::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 toXapian::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 toXapian::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 toXapian::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 toXapian::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 toXapian::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 toXapian::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 functiondoSearch(std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::cxx11::basic_string<char, std::char_traits, std::allocator > > >)': notdeft-xapian.cc:(.text+0x5c64): undefined reference to Xapian::Database::Database()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x5dbf): undefined reference toXapian::Database::Database(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x5dd8): undefined reference to Xapian::Database::add_database(Xapian::Database const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x5dee): undefined reference toXapian::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 toXapian::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 toXapian::QueryParser::QueryParser()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x5f1f): undefined reference to `Xapian::QueryParser::add_prefix(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x5fd3): undefined reference to 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 toXapian::QueryParser::add_prefix(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x613b): undefined reference to 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 toXapian::Stem::Stem(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x61da): undefined reference to Xapian::Query::MatchAll' /usr/bin/ld: notdeft-xapian.cc:(.text+0x6200): undefined reference toXapian::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 toXapian::QueryParser::set_stemming_strategy(Xapian::QueryParser::stem_strategy)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x62c2): undefined reference to `Xapian::QueryParser::parse_query(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x6331): undefined reference to Xapian::Query::get_description[abi:cxx11]() const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x6385): undefined reference toXapian::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 toXapian::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 toXapian::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 toXapian::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 toXapian::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 toXapian::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 toXapian::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 toXapian::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 toXapian::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 toXapian::Error::get_description[abi:cxx11]() const' /usr/bin/ld: /tmp/ccu74YoX.o: in function `doDump(std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::cxx11::basic_string<char, std::char_traits, std::allocator > > >)': notdeft-xapian.cc:(.text+0x7361): undefined reference to `Xapian::Database::Database(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)' /usr/bin/ld: notdeft-xapian.cc:(.text+0x7390): undefined reference to 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 toXapian::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 toXapian::Database::allterms_begin(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x75e5): undefined reference to `Xapian::TermIterator::operator[abi:cxx11]() const' /usr/bin/ld: notdeft-xapian.cc:(.text+0x766b): undefined reference to Xapian::Database::~Database()' /usr/bin/ld: notdeft-xapian.cc:(.text+0x7890): undefined reference toXapian::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 functionXapian::PostingIterator::~PostingIterator()': notdeft-xapian.cc:(.text._ZN6Xapian15PostingIteratorD2Ev[_ZN6Xapian15PostingIteratorD5Ev]+0x20): undefined reference to Xapian::PostingIterator::decref()' /usr/bin/ld: /tmp/ccu74YoX.o: in functionXapian::TermIterator::~TermIterator()': notdeft-xapian.cc:(.text._ZN6Xapian12TermIteratorD2Ev[_ZN6Xapian12TermIteratorD5Ev]+0x20): undefined reference to Xapian::TermIterator::decref()' /usr/bin/ld: /tmp/ccu74YoX.o: in functionXapian::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 toXapian::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 toXapian::TermGenerator::index_text(Xapian::Utf8Iterator const&, unsigned int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' /usr/bin/ld: /tmp/ccu74YoX.o: in function `Xapian::TermGenerator::index_text_without_positions(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)': notdeft-xapian.cc:(.text._ZN6Xapian13TermGenerator28index_text_without_positionsERKNSt7__cxx1112basic_stringIcSt11chartraitsIcESaIcEEEjS8[_ZN6Xapian13TermGenerator28index_text_without_positionsERKNSt7cxx1112basic_stringIcSt11chartraitsIcESaIcEEEjS8]+0x4c): undefined reference to Xapian::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 functionXapian::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 functionXapian::MSetIterator::~MSetIterator()': notdeft-xapian.cc:(.text._ZN6Xapian12MSetIteratorD2Ev[_ZN6Xapian12MSetIteratorD5Ev]+0x14): undefined reference to Xapian::MSet::~MSet()' /usr/bin/ld: /tmp/ccu74YoX.o: in functionXapian::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

WarrenWilkinson commented 5 years ago

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
WarrenWilkinson commented 5 years ago

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`
hasu commented 5 years ago

Thank you, Warren, for finding a fix. I've merged your change.