[Xapian-devel] Trying to get Search::Xapian perl module to compile on win32

Desmond Daignault desmond.daignault at oneil.com
Thu Oct 29 13:51:07 GMT 2015

The disclaimer automatically added and is not intended to limit legitimate discourse, and any code I write for this is expected to be licensed under whatever license the original work is using.

I haven't tried compiling latest code under visual studio yet (is this possible?).  I wonder if there is a way to tell gcc to not mangle the names during cross compile.  I was able to successfully cross compile libxml and a few others without impacting the perl module compile but that is probably due to them being just a C project.


-----Original Message-----	
From: Olly Betts [mailto:olly at survex.com] 
Sent: Wednesday, October 28, 2015 5:35 PM
To: Desmond Daignault <desmond.daignault at oneil.com>
Cc: Xapian Development <xapian-devel at lists.xapian.org>
Subject: Re: [Xapian-devel] Trying to get Search::Xapian perl module to compile on win32

On Wed, Oct 28, 2015 at 08:46:15PM +0000, Desmond Daignault wrote:
> Come to find out, on windows, perl does indeed define open to be win32_open and close to be win32_close.  This is done in perl/lib/CORE/win3iop.h.  So, to get past this problem, I had to modify Xapian.xs to do an #undef of open and close if WIN32 is defined.
> Also, I had to modify the Makefile.PL to not use xapian_config to get the values it needs. 
> Attached is a work in progress patch for both files.  (hope the attachments come through)  I am now getting linking errors.  I am working with the latest stable version of xapian-core, which I cross-compiled on Ubuntu for win32.  I had to do a couple of manual steps to convert the libxapian-22.dll into a libxapian-22.lib using info from https://support.microsoft.com/en-us/kb/131313.  Specifically using dumpbin /exports to create a definition file and then feeding the definition file to lib /def to create the .lib and .exp files.
> The call to generate the Makefile on win32 is now something like: 
>     perl Makefile.PL CXX=cl.exe INC=-IC:\Install\include " LIBS=-lxapian-22 -lzlib" XAPIAN_VERSION=1.2.21 "CXXFLAGS=-EHsc -TP"

Presumably you're cross-compiling with GCC?

> Now when I run nmake, it gets past the compile portion and dies when linking with errors like: 
> Xapian.obj : error LNK2001: unresolved external symbol "public: __thiscall Xapian::WritableDatabase:
> :WritableDatabase(class Xapian::WritableDatabase const &)" (??0WritableDatabase at Xapian@@QAE at ABV01@@Z)
> Any clues on how to resolve the linking errors?

I'd be surprised if you can mix C++ code compiled with GCC with C++ code
compiled with MSVC - you probably need to use either GCC or MSVC to
build both xapian-core and Search::Xapian.  C code should interwork
fine, so it shouldn't matter what perl was built with.

Before I can apply the patches, I need to check you're OK with the
licensing requirements:


Actually for Search::Xapian it ought to be a "same licence as Perl" in
place of "GPL version 2 and all later versions".  (The dual licence with
MIT/X is still useful there as it allows us to apply patches to the
SWIG-based Perl bindings on trunk).

> **********************************************************************
> Confidentiality Notice
> The information contained in this e-mail is confidential and intended for use only by the person(s) or organization listed in the address. If you have received this communication in error, please contact the sender at O'Neil & Associates, Inc., immediately. Any copying, dissemination, or distribution of this communication, other than by the intended recipient, is strictly prohibited.
> **********************************************************************

Also, please explicitly confirm that this notice isn't intended to apply
to the patches.  If we apply them they'll definitely be used by people
you didn't address this email to...


More information about the Xapian-devel mailing list