[Xapian-devel] Sample quickstartindex unable to create database on Windows 2008

Martin Margo martin_margo at yahoo.com
Sat Jul 11 00:26:26 BST 2009

Mark this thread as solved.

Thanks to people at Microsoft
Forum, I learned std::string class is not binary compatible between my
driver project (VC2008 IDE) and Xapian (built using nmake). I have in
my compile option '_DEBUG'. Once I changed my configuration manager to
'Release/Win32' and transferred proper header and include lib dirs, my
program runs successfully.

Hopefully this will help other people in my position. I'm curious if this change will fix Charlie's problem as well.

Here's my thread at Microsoft Forum


----- Original Message ----
From: Olly Betts <olly at survex.com>
To: Charlie Hull <charlie at juggler.net>
Cc: Xapian Development <xapian-devel at lists.xapian.org>
Sent: Thursday, July 2, 2009 9:18:43 PM
Subject: Re: [Xapian-devel] Sample quickstartindex unable to create database on Windows 2008

On Thu, Jul 02, 2009 at 11:43:03AM +0100, Charlie Hull wrote:
> Olly Betts wrote:
> > What is argv[1] as passed to quickstartindex?
> > 
> > And what are these 4 bytes exactly?  They're showing up as 0xcc here,
> > but it's not clear if they've been mangled from their original values.
> > 
> > Or are you looking at the raw data inside the string class?  That would
> > probably have the length followed by the string data.
> I've confirmed this problem on Visual C++ 2005 Express. Debugging inside 
> the WritableDatabase constructor:
> WritableDatabase::WritableDatabase(const std::string &path, int action)
>      : Database()
> {
> The debugger shows 'path' is a '<Bad Ptr>'. Somehow VC++ doesn't like 
> passing const references to std::strings in this way.

It can't be that simple or else very little of Xapian would work, and
indeed a lot of other C++ software would fail as passing std::string
by const reference is very common.  This finds "about 281,000"


It would be good to see what adding "cout << path << endl;" to the
WritableDatabase constructor gave, as that would help rule out this
being bad debug info.

> BTW copying argv[1] into a temporary buffer to make sure it's definitely 
> zero terminated etc., then making a new std::string round it, then 
> passing a reference to that doesn't help.

OK, but what *is* argv[1] (as I asked above)?  It would be useful to
check that the 4 garbage bytes didn't get added already somehow.

And can you reproduce this in a cut down example without Xapian

> I'm wondering (though not with any real evidence) if 
> http://trac.xapian.org/ticket/140
> has any relevance.

No, that was just about which is more efficient, and it turns out that
const reference seems to be regardless of how std::string is


Xapian-devel mailing list
Xapian-devel at lists.xapian.org

More information about the Xapian-devel mailing list