How to build xapian 1.4.10 with MSVC2017

cswuyg 496090217 at qq.com
Thu Feb 21 16:37:37 GMT 2019


Thank you very much,It works!


And some Q&A I meet,may help somebody:
1. If zlib build with 32bit,should use MSVC's 'vcvars32.bat';
2. Add '-Z7' to CXXFLAGS can release *.pdb file for VS2017 'Step Into' debug, such as: CXXFLAGS="-EHsc -Z7";
3. If Somebody write a demo in VS2017
 3.1 change libxapian.a's name to libxapian.lib;
 3.2 make sure the Runtime Library is /MT, can change it at project property page,  C/C++-->Code Generation-->Runtime Library; 
 3.3 add Rpcrt4.lib and Ws2_32.lib to linker input;
 3.4 copy zlib1.dll to the demo.exe's directory, or may get some error like '0xc000007b' at process start.




Cheers,
    cswuyg
------------------ Original ------------------
From:  "Olly Betts";<olly at survex.com>;
Date:  Feb 21, 2019
To:  "cswuyg"<496090217 at qq.com>; 
Cc:  "xapian-discuss"<xapian-discuss at lists.xapian.org>; 
Subject:  Re: How to build xapian 1.4.10 with MSVC2017



On Wed, Feb 20, 2019 at 12:41:07PM +0800, cswuyg wrote:
> Thanks for your reply.
> I had run vcvars64.bat,but still cann't find 'cl'.
> Finally I fix it, change msys2_shell.cmd: "if it is present: replace rem set MSYS2_PATH_TYPE=inherit with set MSYS2_PATH_TYPE=inherit".

OK, I'll note that in the instructions.

It looks like you can also enable this option as a one-off by passing
-use-full-path:

msys2_shell.cmd -use-full-path

> And other errors :
> #   ./configure CC="cl -nologo" CXX="$PWD/compile cl -nologo" CXXFLAGS="-EHsc AR=lib -IC:\zlib-1.2.3-lib\include LDFLAGS=-LC:\zlib-1.2.3-lib\lib" --prefix="C:\xapian-install"

Your quoting is wrong here - there's no closing quote on CXXFLAGS, so this
sets CXXFLAGS to the value:

    -EHsc AR=lib -IC:\zlib-1.2.3-lib\include LDFLAGS=-LC:\zlib-1.2.3-lib\lib

And then doesn't set AR, CPPFLAGS or LDFLAGS at all.

You're also missing CPPFLAGS= before -IC:\zlib-1.2.3-lib\include so
fixing both of those I guess you want:

./configure CC="cl -nologo" CXX="$PWD/compile cl -nologo" CXXFLAGS="-EHsc" AR=lib CPPFLAGS=-IC:\zlib-1.2.3-lib\include LDFLAGS="-LC:\zlib-1.2.3-lib\lib" --prefix="C:\xapian-install"

I don't think that's the cause of your immediate problem, but this will
cause you problems sooner or later.

> checking for egrep... /usr/bin/grep -E
> checking for fgrep... /usr/bin/grep -F
> checking for non-GNU ld... no
> configure: error: no acceptable ld found in $PATH

Looking at the CI logs, it seems that xapian-core's configure there
finds GNU ld, but doesn't actually use it for the build:

https://ci.appveyor.com/project/ojwb/xapian/builds/22443660/job/muwq9r3jmcde4h92?fullLog=true#L844

So probably installing GNU ld from mingw would work around this, but
really you shouldn't need to have it installed as MSVC is used for
linking.

You could try adding LD=link to the configure command line (to tell it
to use the Microsoft linker).

Sorry for the bumpy ride here - it's definitely possible (as the CI
build shows) but this is fairly new and I don't think many people have
tried to replicate that using the instructions in INSTALL yet.

Cheers,
    Olly


More information about the Xapian-discuss mailing list