Support: quest -f cjk_ngram
[xapian.git] / xapian-maintainer-tools / win32msvc / README
blob3d13e0f99a88935e2602dfceeafd901987daa693
1 README for Xapian/Visual C++ Tools
2 ==================================
3 2011-01-07 for Xapian 1.2.4
5 Make files, some extra headers and associated tools for compiling Xapian on
6 Win32 using the Microsoft Visual C++ compilers. This is particularly useful
7 if you're using the Python for Windows binary distribution as this is also
8 compiled with Visual C++; otherwise the only way to make the Python
9 bindings work is to recompile Python with Cygwin (Xapian compiles happily
10 with Cygwin as standard).
12 The project was started by Ulrik Petersen, and continued by Charlie Hull of
13 Lemur Consulting who is now maintaining it.
15 If you have any feedback, bug reports or comments about these files,
16 please DO NOT contact Ulrik, but please contact us at Lemur Consulting
17 www.lemurconsulting.com
19 Runtime requirements
20 ====================
22 If you download a prebuilt version, you need:
24 - Microsoft Windows 2000 or later (NT-based; 95/98/ME won't work)
26 - It will usually be necessary to install the MSVC 2005 redistributable from
27   http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en
29 What works?
30 ===========
32 - The Python, PHP, C#, Ruby bindings (but see below for the latter)
33 - The xapian-compact, xapian-check, xapian-inspect binaries
34 - The xapian-progsrv and xapian-tcpsrv binaries
35 - The delve, quest and copydatabase binaries
36 - The Xapian example binaries
37 - The testsuite, which is run as part of the makefile in tests/, *but* see below regarding the tests
38 - omega, omindex and scriptindex (although these may have difficulty parsing
39   Windows directory paths)
41 What doesn't work - Xapian core
42 ===============================
44 - Warning: unlike Unix, windows does not usually allow open files to be
45   deleted.  This caused a serious problem with releases of Xapian on
46   Windows before version 0.9.10, potentially leading to database
47   corruption.  This is believed to be fixed in version 0.9.10, but there
48   remains a restriction that you must close databases before deleting the
49   folder (and the files in the folder) containing the database.  We do not
50   expect this restriction to be lifted in future releases - equally, we do
51   not expect it to cause serious problems.
53 - To get round the fact that MSVC doesn't do dependency checking correctly,
54   we use an external program 'xapdep'. Each Makefile use the -showIncludes switch of the MSVC
55   compiler to generate a list of includes as deps.d, which xapdep then processes and inserts
56   into the Makefile in the various subdirectories. An unfortunate side effect is that
57   details of any compilation errors may be hidden: if you see:
59   NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
61   this signifies a compilation error while dependencies were being checked. Look at the file
62   deps.d in the appropriate folder to see what actually caused the failure.
63   
64 - The 'replicate3' test currently fails on Windows for the Flint database. 
65 This may be due to the test itself or the replication subsystem, so at 
66 present we do not advise the use of the replication system on Windows when using a 
67 Flint database. The test also hangs forever with the Brass database: if you want to run all 
68 the other tests (with 'nmake check') you can comment out lines 470-512 of api_replicate.cc.
70 - The 'compactstub3' and 'compactstub4' tests fail on Windows. If you want to run all 
71 the other tests (with 'nmake check') you can comment out lines 361-383 and 389-413 of api_compact.cc.
73 What doesn't work - Xapian bindings
74 ===================================
76 - The ruby bindings fail one of the tests, see http://trac.xapian.org/ticket/478 for
77 more details. We have opted to package them anyway (see win32_bindings_ruby.mak for how)
79 - Any other bindings.
81 TODOS
82 =====
84 Other bindings
86 How do I get the released sources?
87 ==================================
89 You will need an archive tool which can uncompress .zip and .tgz archives.
90 A free tool which is suitable for this purpose is available from
91 http://www.7-zip.org/.
93 1. Download and unpack Xapian, the Xapian bindings and Omega to the same
94    folder. You should have a structure like this (the top level folder
95    doesn't have to be called 'xapian'):
97 xapian\
98 xapian\xapian-core-0.x.y
99 xapian\xapian-bindings-0.x.y
100 xapian\omega-0.x.y
102 where x and y are revision numbers.
104 2. Download win32.zip for the appropriate Xapian release from Lemur
105    Consulting and place in xapian\xapian-core-0.x.y.
106 3. Extract the files to the win32/ folder (usually, right click on the ZIP
107    file and select Extract Here).
108 4. IMPORTANT - Edit config.mak to make sure the various individual mak
109    files end up in the right folders, and add the correct paths for any
110    other binding languages. You may also need to edit the
111    win32_applications_omega.mak and win32_bindings_python.mak files, and
112    the .mak files for any other bindings. Note that all the .mak files in
113    the win32/ folder are automatically copied to the correct places at the
114    beginning of the build process, so edit them here rather than where they
115    end up.
117 How do I get the latest development sources?
118 ============================================
120 The development sources are held in a revision control system called git, so
121 you will first need a git client installed to build the latest development
122 sources.  Details of how to access the xapian repository are available at
123 http://xapian.org/bleeding
125 When you check out the xapian sources, you will have a slightly different
126 structure than that derived from the release tarballs:
128 xapian\xapian-core
129 xapian\xapian-bindings
130 xapian\xapian-applications
131 xapian\xapian-maintainer-tools
132 xapian\swig
134 After checking out the sources, copy the contents of the
135 "xapian\xapian-maintainer-tools\win32msvc" directory to a new directory named
136 "xapian\xapian-core\win32". Run the build from this latter directory.
138 You will then need to edit "xapian\xapian-core\win32\config.mak" as
139 described in step 4 in the previous section ("How do I get the released
140 sources?").
142 What do I need to compile it?
143 =============================
145 You will need:
147 - Windows 2000 or later (NT-based; 95/98/ME won't work)
149 - Visual C++ 7.0 (.Net 2003/2005). In particular:
150   - cl.exe
151   - link.exe
152   - lib.exe
153   - nmake.exe
155   OR...
157 - You can also compile with
158 Visual C++ 2005/2008 Express Edition available without cost from:
159 http://msdn.microsoft.com/vstudio/express/visualc/default.aspx
161   OR...
163 - You can also compile with
164 Visual C++ Toolkit 2003, if you can find it (Microsoft don't distribute this any more) and in this case you'll need the .NET 1.1 SDK:
165 http://www.microsoft.com/downloads/details.aspx?FamilyID=9b3a2ca6-3647-4070-9f41-a333c6b9181d&displaylang=en
166 and also to create or download msvcprt.lib, details on how to do this are here:
167 http://root.cern.ch/root/Procedure/Procedure%20to%20install%20the%20free%20Microsoft%20Visual%20C.htm
169 If you *don't* use Visual C++ 7.0 then you'll also need the Platform SDK:
170 http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
171  the "Windows® Server 2003 SP1 Platform SDK" is recommended.
172 which contains headers, libs and NMAKE.
174 - Perl is used to pre-build some of the source files. Install a Win32 binary from ActiveState (http://www.activestate.com/Products/ActivePerl/) and modify config.mak appropriately (PERL_DIR)
176 - You will also need the ZLIB library. Download and unzip the binary Windows package
177 http://www.zlib.net/zlib123-dll.zip
178 and make sure the path to where you downloaded it matches the path in config.mak (ZLIB_DIR).
180 - For Omega you will need the PCRE library. Download from 
181 http://gnuwin32.sourceforge.net/downlinks/pcre.php
182 (we have used pcre-7.0.exe)
183 and make sure the path to where you downloaded it matches the path in config.mak (PCRE_DIR).
185 - To compile the Python bindings you need Python from www.python.org. Make sure the paths to this are set correctly in config.mak (PYTHON_DIR). 
186 Note that the build system supports Python 2.4, 2.5, 2.6  and 2.7 currently, you must specify which you require.
188 - To compile the PHP bindings for PHP 5.2 you need:
190   a. the PHP sources from www.php.net (we have used 5.2.1).
191   b. the built sources from a Windows binary distribution
192   c. to edit config.mak to use the correct paths to PHP 5.2 and to select the right version of PHP to build.
193   
194 - To compile the PHP bindings for PHP 5.3 you need to:
196   a. follow the instructions at http://wiki.php.net/internals/windows/stepbystepbuild
197   b. to edit config.mak to use the correct paths to PHP 5.3 and to select the right version of PHP to build.
199 - To compile the Java bindings you need the Java SE Development Kit from http://java.sun.com/javase/downloads/index.jsp (we have used the 1.6.0_05 release). Make sure the paths to this are set correctly in config.mak (JAVA_DIR)
201 - To compile the Ruby bindings you will need the one-click installer for Ruby 1.8.6 from http://www.ruby-lang.org/en/downloads/ - config.mak has settings that will work if this is installed at the default location of c:\ruby. Note that you will have to change the "!=" in the first line of c:\ruby\lib\ruby\1.8\i386-mswin32\config.h
202 to "<=" if using a Visual C++ older than 5.0.
204 - To compile the C# bindings you will need the .NET 1.1 SDK (see above) and Visual C# (the Express 2005 edition works, available from:
205 http://www.microsoft.com/express/2005/). Note that the bindings are produced as two separate DLLs: your C# program will need to import the right one,
206 see how the Smoketest is built in win32_bindings_csharp.mak for details.
208 - SWIG is used for recompiling the bindings, but this is done by the Xapian core maintainers, so you shouldn't need to do this unless you are building from the development sources, in which case you'll have to use the version of SWIG in the Xapian repository. To build this follow the instructions at
209 xapian\swig\Doc\Manual\Windows.html
210 (you'll need to install MinGW).
211 To make sure the bindings are rebuilt use the following when building in the bindings folders:
213 nmake SWIGBUILD=1
215 Make sure the paths to this are set correctly in config.mak (SWIG)
217 How do I compile it from a command prompt?
218 ==========================================
220 1a) Run SetEnv.cmd in the Platform SDK to make sure the SDK's paths are added to your environment. For the "Windows Server 2003 SP1 Platform SDK", installed to the default folder, use the following command:
221 C:\Program Files\Microsoft Platform SDK\SetEnv.cmd" /RETAIL
223 1b) Run vcvars32.bat or equivalent for the C compiler to make sure the paths to the compiler are added to your environment. This may be listed as 'Command Prompt' in the Programs menu entry.
224 For Visual C++ 2005 Express Edition installed to the default folder, use the following command:
225 C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat
227 1c) If you are using the Express compiler, you'll need to add an include path:
228 set INCLUDE=%INCLUDE%;%MSSDK%\Include\mfc
230 1d) If you are using the 2003 Toolkit compiler, and you've thus installed the .NET 1.1 SDK, you'll need to add a library path:
231 set LIB=%LIB%;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib;
233 --------
234 NOTE: It's easiest to automate the preceding steps. To do this, put the commands above (or the equivalent on your system) into a text file with the .cmd extension (let's call it 'xapenv.cmd'). You could also add a 'cd' to wherever your xapian code is located. Then right-click on your desktop, select New, Shortcut, and find C:\Windows\System32\cmd.exe. Right-click on the new shortcut and select Properties. Edit the Target field to read:
235 %SystemRoot%\system32\cmd.exe /a /k c:\xapenv "%1"
236 You can now just run the shortcut to open a command line window ready for building Xapian.
237 --------
239 To build the Xapian core:
241 2) cd to xapian-core-0.x.y\win32 or the appropriate path on your system.
242 3) edit config.mak to suit your environment
243 4) nmake CLEAN
244 either:
245 5a) nmake CHECK
246    - to build and run the test suite
247 5b) nmake
248    - to just build.
249     
250 **NOTE: if you get the following error:
252     NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
254     this signifies a compilation error while dependencies were being checked. Look at the file
255     deps.d in the appropriate folder to see what actually caused the failure.
257 To build the bindings (do steps 1-5 above first to make sure you have Xapian built):
259 6) cd to xapian-core-0.x.y\win32 or the appropriate path on your system.
260 7) edit 
261   win32_bindings_python.mak
262   win32_bindings_php.mak
263   win32_bindings_ruby.mak 
264   win32_bindings_java.mak
265   win32_bindings_csharp.mak
266     to suit your environment (XAPIAN_CORE_REL_PYTHON or similar)
267 8) nmake COPYMAKFILES
268    - to make sure this change is copied to the build folder (this is also done by a rebuild of Xapian)
269 9) cd to ..\..\xapian-bindings-0.x.y\ and then the binding folder (php, python etc.)
270 10) nmake CLEAN
271 11a) nmake CHECK
272    - to build and run the test suite
273 11b) nmake
274    - to just build.
275 11c) nmake DIST
276    - to build, CHECK and also create a /dist subfolder containing a binary distribution, documentation and examples
277 11d) nmake SWIGBUILD=1
278    - to build from the development sources using SWIG (see above)
280 11e) For Python only, add an extra flag before CLEAN, CHECK or DIST:
281     nmake PYTHON_VER=24 ..
282  to make bindings for Python 2.4 or
283     nmake PYTHON_VER=25 ..
284  etc.
286 11f) For Ruby only, use
287     nmake INSTALL
288  to install the bindings to the standard Ruby library folder.
290 11g) For PHP only, use 
291     nmake PHP_VER=52
292   to make bindings for PHP 5.2.x, or
293     nmake PHP_VER=53
294   to make bindings for PHP 5.3.x
296  To build *all* the bindings (usually only done by those distributing binaries):
298 12) cd to xapian-core-0.x.y\win32 or the appropriate path on your system.
299 13) nmake MAKEALLBINDINGS
300     - this will build Xapian if not already available. You will need build environments for all
301     the bindings described above available.
303  To build Omega (do steps 1-5 above first to make sure you have Xapian built):
305 14) edit win32_applications_omega.mak to suit your environment (XAPIAN_CORE_REL_OMEGA)
306 15) nmake COPYMAKFILES
307    - to make sure this change is copied to the build folder
308 16) cd to ..\..\omega-0.x.y
309 17) nmake
310    - to build.
312 The binaries end up in xapian-core-0.x.y\win32\Release or \Debug if you are building a Debug build (see below). 
313 If you build using nmake DIST you will see a further /dist subfolder in each bindings's folder, containing 
314  a binary distribution, documentation and examples.
316 There is also a Python file designed to package up all the bindings for a particular release. To run this,
317 install Python 2.4 - 2.6 and :
319 18) python makebinaries.py x.y.z
321 where x.y.z is the release number, e.g. 1.0.14
323 Debug builds
324 ===========
326 To compile Debug builds, run the build process with the following switch:
328 nmake DEBUG=1
330 This affects some lines in config.mak.
332 If you would like verbose Xapian debugging enabled, add -D XAPIAN_DEBUG_VERBOSE to the CPPFLAGS_EXTRA define in config.mak. You will also need to set up correct environment variables so the Xapian debugger knows where to write its log file. Type the following at a command prompt:
334 set XAPIAN_DEBUG_LOG=c:/xap.log
335 set XAPIAN_DEBUG_FLAGS=-1
337 This will create a log file at c:/xap.log and set the debugging bitmask to show all possible messages. To filter out some of the messages, look at om_debug_types in omdebug.h and set XAPIAN_DEBUG_FLAGS accordingly. For example, to show only OM_DEBUG_REMOTE and OM_DEBUG_API messages, you will need a bitmask according to their position in the table: 1000001000000 in binary (4160 decimal), so:
339 set XAPIAN_DEBUG_FLAGS=4160
341 Using the Visual C++ IDE
342 ========================
344 It is also possible to manually create a project in the Visual C++ Express Edition IDE. To build part of Xapian in the IDE you should add to the project all the .cc files in the api, backends, common, expand, languages, matcher, net, queryparser and unicode subfolders of xapian-core, then add the file containing the main loop for whatever you are building (for example if you're building xapian-check, add xapian-check.cc). You will need to examine config.mak to see what include paths to use and any other necessary compiler switches.
347 Please send any bugfixes to Charlie Hull at Lemur Consulting:
348 www.lemurconsulting.com