@@ -8,8 +8,11 @@ This document contains the following sections:
8
8
The C++ wrapper functions
9
9
Building for virtual Pascal
10
10
Stack size in Windows environments
11
+ Linking programs in Windows environments
11
12
Comments about Win32 builds
12
- Building PCRE with CMake
13
+ Building PCRE on Windows with CMake
14
+ Use of relative paths with CMake on Windows
15
+ Testing with runtest.bat
13
16
Building under Windows with BCC5.5
14
17
Building PCRE on OpenVMS
15
18
@@ -31,10 +34,12 @@ library consists entirely of code written in Standard C, and so should compile
31
34
successfully on any system that has a Standard C compiler and library. The C++
32
35
wrapper functions are a separate issue (see below).
33
36
34
- The PCRE distribution includes support for CMake. This support is relatively
35
- new, but has already been used successfully to build PCRE in multiple build
36
- environments on Windows. There are some instructions in the section entitled
37
- "Building PCRE with CMake" below.
37
+ The PCRE distribution includes a "configure" file for use by the Configure/Make
38
+ build system, as found in many Unix-like environments. There is also support
39
+ support for CMake, which some users prefer, in particular in Windows
40
+ environments. There are some instructions for CMake under Windows in the
41
+ section entitled "Building PCRE with CMake" below. CMake can also be used to
42
+ build PCRE in Unix-like systems.
38
43
39
44
40
45
GENERIC INSTRUCTIONS FOR THE PCRE C LIBRARY
@@ -177,15 +182,22 @@ significantly slower when this is done. There is more about stack usage in the
177
182
"pcrestack" documentation.
178
183
179
184
185
+ LINKING PROGRAMS IN WINDOWS ENVIRONMENTS
186
+
187
+ If you want to statically link a program against a PCRE library in the form of
188
+ a non-dll .a file, you must define PCRE_STATIC before including pcre.h,
189
+ otherwise the pcre_malloc() and pcre_free() exported functions will be declared
190
+ __declspec(dllimport), with unwanted results.
191
+
192
+
180
193
COMMENTS ABOUT WIN32 BUILDS (see also "BUILDING PCRE WITH CMAKE" below)
181
194
182
195
There are two ways of building PCRE using the "configure, make, make install"
183
196
paradigm on Windows systems: using MinGW or using Cygwin. These are not at all
184
197
the same thing; they are completely different from each other. There is also
185
- some experimental, undocumented support for building using "cmake", which you
186
- might like to try if you are familiar with "cmake". However, at the present
187
- time, the "cmake" process builds only a static library (not a dll), and the
188
- tests are not automatically run.
198
+ support for building using CMake, which some users find a more straightforward
199
+ way of building PCRE under Windows. However, the tests are not run
200
+ automatically when CMake is used.
189
201
190
202
The MinGW home page (http://www.mingw.org/) says this:
191
203
@@ -217,10 +229,13 @@ also link with libpcre, which contains the basic functions. (Some earlier
217
229
releases of PCRE included the basic libpcre functions in libpcreposix. This no
218
230
longer happens.)
219
231
220
- If you want to statically link your program against a non-dll .a file, you must
221
- define PCRE_STATIC before including pcre.h, otherwise the pcre_malloc() and
222
- pcre_free() exported functions will be declared __declspec(dllimport), with
223
- unwanted results.
232
+ A user submitted a special-purpose patch that makes it easy to create
233
+ "pcre.dll" under mingw32 using the "msys" environment. It provides "pcre.dll"
234
+ as a special target. If you use this target, no other files are built, and in
235
+ particular, the pcretest and pcregrep programs are not built. An example of how
236
+ this might be used is:
237
+
238
+ ./configure --enable-utf --disable-cpp CFLAGS="-03 -s"; make pcre.dll
224
239
225
240
Using Cygwin's compiler generates libraries and executables that depend on
226
241
cygwin1.dll. If a library that is generated this way is distributed,
@@ -252,44 +267,73 @@ terminators in order to get some of the tests to work. We hope to improve
252
267
things in this area in future.
253
268
254
269
255
- BUILDING PCRE WITH CMAKE
270
+ BUILDING PCRE ON WINDOWS WITH CMAKE
256
271
257
272
CMake is an alternative build facility that can be used instead of the
258
273
traditional Unix "configure". CMake version 2.4.7 supports Borland makefiles,
259
274
MinGW makefiles, MSYS makefiles, NMake makefiles, UNIX makefiles, Visual Studio
260
275
6, Visual Studio 7, Visual Studio 8, and Watcom W8. The following instructions
261
276
were contributed by a PCRE user.
262
277
263
- 1. Download CMake 2.4.7 or above from http://www.cmake.org/, install and ensure
264
- that cmake\bin is on your path.
278
+ 1. Download CMake 2.4.7 or above from http://www.cmake.org/, install and ensure
279
+ that cmake\bin is on your path.
265
280
266
- 2. Unzip (retaining folder structure) the PCRE source tree into a source
267
- directory such as C:\pcre.
281
+ 2. Unzip (retaining folder structure) the PCRE source tree into a source
282
+ directory such as C:\pcre.
268
283
269
- 3. Create a new, empty build directory: C:\pcre\build\
284
+ 3. Create a new, empty build directory: C:\pcre\build\
270
285
271
- 4. Run CMakeSetup from the Shell envirornment of your build tool, e.g., Msys
272
- for Msys/MinGW or Visual Studio Command Prompt for VC/VC++
286
+ 4. Run CMakeSetup from the Shell envirornment of your build tool, e.g., Msys
287
+ for Msys/MinGW or Visual Studio Command Prompt for VC/VC++
273
288
274
- 5. Enter C:\pcre\pcre-xx and C:\pcre\build for the source and build
275
- directories, respectively
289
+ 5. Enter C:\pcre\pcre-xx and C:\pcre\build for the source and build
290
+ directories, respectively
276
291
277
- 6. Hit the "Configure" button.
292
+ 6. Hit the "Configure" button.
278
293
279
- 7. Select the particular IDE / build tool that you are using (Visual Studio,
280
- MSYS makefiles, MinGW makefiles, etc.)
294
+ 7. Select the particular IDE / build tool that you are using (Visual Studio,
295
+ MSYS makefiles, MinGW makefiles, etc.)
281
296
282
- 8. The GUI will then list several configuration options. This is where you can
283
- enable UTF-8 support, etc.
297
+ 8. The GUI will then list several configuration options. This is where you can
298
+ enable UTF-8 support, etc.
284
299
285
- 9. Hit "Configure" again. The adjacent "OK" button should now be active.
300
+ 9. Hit "Configure" again. The adjacent "OK" button should now be active.
286
301
287
302
10. Hit "OK".
288
303
289
304
11. The build directory should now contain a usable build system, be it a
290
305
solution file for Visual Studio, makefiles for MinGW, etc.
291
306
292
- Testing with RunTest.bat
307
+
308
+ USE OF RELATIVE PATHS WITH CMAKE ON WINDOWS
309
+
310
+ A PCRE user comments as follows:
311
+
312
+ I thought that others may want to know the current state of
313
+ CMAKE_USE_RELATIVE_PATHS support on Windows.
314
+
315
+ Here it is:
316
+ -- AdditionalIncludeDirectories is only partially modified (only the
317
+ first path - see below)
318
+ -- Only some of the contained file paths are modified - shown below for
319
+ pcre.vcproj
320
+ -- It properly modifies
321
+
322
+ I am sure CMake people can fix that if they want to. Until then one will
323
+ need to replace existing absolute paths in project files with relative
324
+ paths manually (e.g. from VS) - relative to project file location. I did
325
+ just that before being told to try CMAKE_USE_RELATIVE_PATHS. Not a big
326
+ deal.
327
+
328
+ AdditionalIncludeDirectories="E:\builds\pcre\build;E:\builds\pcre\pcre-7.5;"
329
+ AdditionalIncludeDirectories=".;E:\builds\pcre\pcre-7.5;"
330
+
331
+ RelativePath="pcre.h">
332
+ RelativePath="pcre_chartables.c">
333
+ RelativePath="pcre_chartables.c.rule">
334
+
335
+
336
+ TESTING WITH RUNTEST.BAT
293
337
294
338
1. Copy RunTest.bat into the directory where pcretest.exe has been created.
295
339
@@ -384,5 +428,5 @@ $! Locale could not be set to fr
384
428
$!
385
429
=========================
386
430
387
- Last Updated: 21 September 2007
431
+ Last Updated: 25 January 2008
388
432
****
0 commit comments