[Xapian-devel] Add an example to the community page and contribute more code

Olly Betts olly at survex.com
Sun Jan 20 21:10:47 GMT 2013


On Mon, Jan 21, 2013 at 12:21:51AM +0530, aarsh shah wrote:
> Hey there Olly,hope you are fine . :) I have the code for Paice Husk ready
> .But I am not being able to modify the Xapian source code I have downloaded.
> 
> I modified the stem.cc file so that get_description() returns a default
> welcome string insead of calling the internal get_description() method
> (just for fun ) .I than used make and make install again and then wrote a
> simple indexer which called the stem.get_description() method .However,I
> got the original string instead of the one I had modified.Why didn't the
> change I had made get reflected ? I know this is a naive question but I am
> new to open source and have never modified open source code before.Sorry
> for taking up your time.I tried everything I could ,( even built the entire
> code again) but nothing happened.

It's not a naive question, though I suspect it is a common pitfall
you've run into.

If you're on a platform where Xapian is installed by default, such as
Debian or Ubuntu, then you'll already have a copy of the xapian runtime
shared library installed in /usr/lib (or some equivalent multiarch
directory, such as /usr/lib/x86_64-linux-gnu).  The exact filename
will depend on the OS and the version of Xapian, but for xapian-core 1.2
on Linux, it's libxapian.so.22 (the 22 tells you this is ABI compatible
with other builds which produce libxapian.so.22).

If you build a version of xapian-core which produces libxapian.so.22
(which roughly speaking means any version 1.2.x), and install this, it
will go in /usr/local/lib by default, but the dynamic linker will look
under /usr/lib first and find the system version.

On Linux, you can see which libxapian you're getting by running "ldd" on
a binary:

$ ldd /usr/bin/xapian-compact
	linux-vdso.so.1 =>  (0x00007fff3855e000)
	libxapian.so.22 => /usr/lib/libxapian.so.22 (0x00007f544c029000)
[snip]

On Linux, you can set LD_LIBRARY_PATH to tell the dynamic linker where
to look first (other platforms usually have a similar environmental
variable, but it may have a different name):

$ LD_LIBRARY_PATH=/usr/local/lib ldd /usr/bin/xapian-compact
	linux-vdso.so.1 =>  (0x00007fffb03ff000)
	libxapian.so.22 => /usr/local/lib/libxapian.so.22 (0x00007f0c22fda000)

None of this is specific to Xapian (except the filenames in the
examples) - you'll hit the same issues dealing with parallel installs of
any shared library.

> The code for the paice husk stemmer is ready and Ive understood how to use
> it for indexing.Ir am supposed to inherit Xapian::StemImplementation
> ,implement the pure virtual  functions(have already done that)  and than
> pass a reference  to the inherited object to
> Xapian::Stem::Stem(StemImplementaion *pointer) ,right ? :)

To be clear, you pass a pointer, not a reference (the two terms have
particular meanings in C++).  Note that the Stem object you construct
takes ownership of the pointer, so you want to create your subclass
object with new, e.g.:

    Xapian::Stem s(new StemImplementationPaiceHusk());

Cheers,
    Olly



More information about the Xapian-devel mailing list