| 1 |
Compiling PCRE on non-Unix systems |
Compiling PCRE on non-Unix systems |
| 2 |
---------------------------------- |
---------------------------------- |
| 3 |
|
|
| 4 |
See below for comments on Cygwin or MinGW and OpenVMS usage. I (Philip Hazel) |
I (Philip Hazel) have no knowledge of Windows or VMS sytems and how their |
| 5 |
have no knowledge of Windows or VMS sytems and how their libraries work. The |
libraries work. The items in the PCRE distribution and Makefile that relate to |
| 6 |
items in the PCRE Makefile that relate to anything other than Unix-like systems |
anything other than Unix-like systems are untested by me. |
| 7 |
have been contributed by PCRE users. There are some other comments and files in |
|
| 8 |
the Contrib directory on the ftp site that you may find useful. See |
There are some other comments and files in the Contrib directory on the ftp |
| 9 |
|
site that you may find useful, although a lot of them are now out-of-date. See |
| 10 |
|
|
| 11 |
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib |
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib |
| 12 |
|
|
| 13 |
If you want to compile PCRE for a non-Unix system (or perhaps, more strictly, |
If you want to compile PCRE for a non-Unix system (or perhaps, more strictly, |
| 14 |
for a system that does not support "configure" and "make" files), note that |
for a system that does not support "configure" and "make" files), note that |
| 15 |
PCRE consists entirely of code written in Standard C, and so should compile |
the basic PCRE library consists entirely of code written in Standard C, and so |
| 16 |
successfully on any system that has a Standard C compiler and library. |
should compile successfully on any system that has a Standard C compiler and |
| 17 |
|
library. The C++ wrapper functions are a separate issue (see below). |
| 18 |
|
|
| 19 |
|
|
| 20 |
GENERIC INSTRUCTIONS FOR THE C LIBRARY |
GENERIC INSTRUCTIONS FOR THE C LIBRARY |
| 21 |
|
|
| 22 |
The following are generic comments about building PCRE. The interspersed |
The following are generic comments about building the PCRE C library "by hand". |
|
indented commands are suggestions from Mark Tetrode as to which commands you |
|
|
might use on a Windows system to build a static library. |
|
|
|
|
|
(1) Copy or rename the file config.in as config.h, and change the macros that |
|
|
define HAVE_STRERROR and HAVE_MEMMOVE to define them as 1 rather than 0. |
|
|
Unfortunately, because of the way Unix autoconf works, the default setting has |
|
|
to be 0. You may also want to make changes to other macros in config.h. In |
|
|
particular, if you want to force a specific value for newline, you can define |
|
|
the NEWLINE macro. The default is to use '\n', thereby using whatever value |
|
|
your compiler gives to '\n'. |
|
|
|
|
|
rem Mark Tetrode's commands |
|
|
copy config.in config.h |
|
|
rem Use write, because notepad cannot handle UNIX files. Change values. |
|
|
write config.h |
|
|
|
|
|
(2) Copy or rename the file pcre.in as pcre.h, and change the macro definitions |
|
|
for PCRE_MAJOR, PCRE_MINOR, and PCRE_DATE near its start to the values set in |
|
|
configure.in. |
|
|
|
|
|
rem Mark Tetrode's commands |
|
|
copy pcre.in pcre.h |
|
|
rem Read values from configure.in |
|
|
write configure.in |
|
|
rem Change values |
|
|
write pcre.h |
|
| 23 |
|
|
| 24 |
(3) Compile dftables.c as a stand-alone program, and then run it with |
(1) Copy or rename the file config.h.generic as config.h, and edit the macro |
| 25 |
the single argument "pcre_chartables.c". This generates a set of standard |
settings that it contains to whatever is appropriate for your environment. |
| 26 |
character tables and writes them to that file. |
In particular, if you want to force a specific value for newline, you can |
| 27 |
|
define the NEWLINE macro. |
| 28 |
|
|
| 29 |
|
An alternative approach is not to edit config.h, but to use -D on the |
| 30 |
|
compiler command line to make any changes that you need. |
| 31 |
|
|
| 32 |
|
(2) Copy or rename the file pcre.h.generic as pcre.h. |
| 33 |
|
|
| 34 |
rem Mark Tetrode's commands |
(3) Compile dftables.c as a stand-alone program, and then run it with |
| 35 |
rem Compile & run |
the single argument "pcre_chartables.c". This generates a set of standard |
| 36 |
cl -DSUPPORT_UTF8 -DSUPPORT_UCP dftables.c |
character tables and writes them to that file. |
|
dftables.exe chartables.c |
|
| 37 |
|
|
| 38 |
(4) Compile the following source files: |
(4) Compile the following source files: |
| 39 |
|
|
| 40 |
pcre_chartables.c |
pcre_chartables.c |
| 41 |
pcre_compile.c |
pcre_compile.c |
| 42 |
pcre_config.c |
pcre_config.c |
| 43 |
pcre_dfa_exec.c |
pcre_dfa_exec.c |
| 44 |
pcre_exec.c |
pcre_exec.c |
| 45 |
pcre_fullinfo.c |
pcre_fullinfo.c |
| 46 |
pcre_get.c |
pcre_get.c |
| 47 |
pcre_globals.c |
pcre_globals.c |
| 48 |
pcre_info.c |
pcre_info.c |
| 49 |
pcre_maketables.c |
pcre_maketables.c |
| 50 |
pcre_ord2utf8.c |
pcre_newline.c |
| 51 |
pcre_printint.c |
pcre_ord2utf8.c |
| 52 |
pcre_refcount.c |
pcre_refcount.c |
| 53 |
pcre_study.c |
pcre_study.c |
| 54 |
pcre_tables.c |
pcre_tables.c |
| 55 |
pcre_try_flipped.c |
pcre_try_flipped.c |
| 56 |
pcre_ucp_findchar.c |
pcre_ucp_searchfuncs.c |
| 57 |
pcre_valid_utf8.c |
pcre_valid_utf8.c |
| 58 |
pcre_version.c |
pcre_version.c |
| 59 |
pcre_xclass.c |
pcre_xclass.c |
| 60 |
|
|
| 61 |
and link them all together into an object library in whichever form your system |
Now link them all together into an object library in whichever form your |
| 62 |
keeps such libraries. This is the pcre C library. If your system has static and |
system keeps such libraries. This is the basic PCRE C library. If your |
| 63 |
shared libraries, you may have to do this once for each type. |
system has static and shared libraries, you may have to do this once for |
| 64 |
|
each type. |
|
rem These comments are out-of-date, referring to a previous release which |
|
|
rem had fewer source files. Replace with the file names from above. |
|
|
rem Mark Tetrode's commands, for a static library |
|
|
rem Compile & lib |
|
|
cl -DSUPPORT_UTF8 -DSUPPORT_UCP -DPOSIX_MALLOC_THRESHOLD=10 /c maketables.c get.c study.c pcre.c |
|
|
lib /OUT:pcre.lib maketables.obj get.obj study.obj pcre.obj |
|
| 65 |
|
|
| 66 |
(5) Similarly, compile pcreposix.c and link it (on its own) as the pcreposix |
(5) Similarly, compile pcreposix.c and link it (on its own) as the pcreposix |
| 67 |
library. |
library. |
|
|
|
|
rem Mark Tetrode's commands, for a static library |
|
|
rem Compile & lib |
|
|
cl -DSUPPORT_UTF8 -DSUPPORT_UCP -DPOSIX_MALLOC_THRESHOLD=10 /c pcreposix.c |
|
|
lib /OUT:pcreposix.lib pcreposix.obj |
|
| 68 |
|
|
| 69 |
(6) Compile the test program pcretest.c. This needs the functions in the |
(6) Compile the test program pcretest.c. This needs the functions in the |
| 70 |
pcre and pcreposix libraries when linking. |
pcre and pcreposix libraries when linking. |
|
|
|
|
rem Mark Tetrode's commands |
|
|
rem compile & link |
|
|
cl /F0x400000 pcretest.c pcre.lib pcreposix.lib |
|
| 71 |
|
|
| 72 |
(7) Run pcretest on the testinput files in the testdata directory, and check |
(7) Run pcretest on the testinput files in the testdata directory, and check |
| 73 |
that the output matches the corresponding testoutput files. You must use the |
that the output matches the corresponding testoutput files. Note that the |
| 74 |
-i option when checking testinput2. Note that the supplied files are in Unix |
supplied files are in Unix format, with just LF characters as line |
| 75 |
format, with just LF characters as line terminators. You may need to edit them |
terminators. You may need to edit them to change this if your system uses a |
| 76 |
to change this if your system uses a different convention. |
different convention. |
|
|
|
|
rem Mark Tetrode's commands |
|
|
pcretest testdata\testinput1 testdata\myoutput1 |
|
|
windiff testdata\testoutput1 testdata\myoutput1 |
|
|
pcretest -i testdata\testinput2 testdata\myoutput2 |
|
|
windiff testdata\testoutput2 testdata\myoutput2 |
|
|
pcretest testdata\testinput3 testdata\myoutput3 |
|
|
windiff testdata\testoutput3 testdata\myoutput3 |
|
|
pcretest testdata\testinput4 testdata\myoutput4 |
|
|
windiff testdata\testoutput4 testdata\myoutput4 |
|
|
pcretest testdata\testinput5 testdata\myoutput5 |
|
|
windiff testdata\testoutput5 testdata\myoutput5 |
|
|
pcretest testdata\testinput6 testdata\myoutput6 |
|
|
windiff testdata\testoutput6 testdata\myoutput6 |
|
| 77 |
|
|
| 78 |
Note that there are now three more tests (7, 8, 9) that did not exist when Mark |
(8) If you want to use the pcregrep command, compile and link pcregrep.c; it |
| 79 |
wrote those comments. The test the new pcre_dfa_exec() function. |
uses only the basic PCRE library (it does not need the pcreposix library). |
| 80 |
|
|
| 81 |
|
|
| 82 |
THE C++ WRAPPER FUNCTIONS |
THE C++ WRAPPER FUNCTIONS |
| 83 |
|
|
| 84 |
The PCRE distribution now contains some C++ wrapper functions and tests, |
The PCRE distribution also contains some C++ wrapper functions and tests, |
| 85 |
contributed by Google Inc. On a system that can use "configure" and "make", |
contributed by Google Inc. On a system that can use "configure" and "make", |
| 86 |
the functions are automatically built into a library called pcrecpp. It should |
the functions are automatically built into a library called pcrecpp. It should |
| 87 |
be straightforward to compile the .cc files manually on other systems. The |
be straightforward to compile the .cc files manually on other systems. The |
| 89 |
xxx.cc files. |
xxx.cc files. |
| 90 |
|
|
| 91 |
|
|
| 92 |
FURTHER REMARKS |
BUILDING FOR VIRTUAL PASCAL |
| 93 |
|
|
| 94 |
|
Stefan Weber contributed the following files in the distribution for building |
| 95 |
|
PCRE for use with VP/Borland: makevp-compile.txt, makevp-linklib.txt, |
| 96 |
|
makevp.bat, pcregexp.pas. |
| 97 |
|
|
| 98 |
|
|
| 99 |
|
BUILDING UNDER WINDOWS WITH BCC5.5 |
| 100 |
|
|
| 101 |
|
Michael Roy sent these comments about building PCRE under Windows with BCC5.5: |
| 102 |
|
|
| 103 |
|
Some of the core BCC libraries have a version of PCRE from 1998 built in, |
| 104 |
|
which can lead to pcre_exec() giving an erroneous PCRE_ERROR_NULL from a |
| 105 |
|
version mismatch. I'm including an easy workaround below, if you'd like to |
| 106 |
|
include it in the non-unix instructions: |
| 107 |
|
|
| 108 |
|
When linking a project with BCC5.5, pcre.lib must be included before any of |
| 109 |
|
the libraries cw32.lib, cw32i.lib, cw32mt.lib, and cw32mti.lib on the command |
| 110 |
|
line. |
| 111 |
|
|
| 112 |
|
|
| 113 |
|
OUT-OF-DATE COMMENTS ABOUT WIN32 BUILDS |
| 114 |
|
|
| 115 |
If you have a system without "configure" but where you can use a Makefile, edit |
[These comments need looking at by someone who knows about Windows.] |
|
Makefile.in to create Makefile, substituting suitable values for the variables |
|
|
at the head of the file. |
|
| 116 |
|
|
| 117 |
Some help in building a Win32 DLL of PCRE in GnuWin32 environments was |
Some help in building a Win32 DLL of PCRE in GnuWin32 environments was |
| 118 |
contributed by Paul Sokolovsky. These environments are Mingw32 |
contributed by Paul Sokolovsky. These environments are Mingw32 |