/[pcre]/code/trunk/NON-UNIX-USE
ViewVC logotype

Diff of /code/trunk/NON-UNIX-USE

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 62 by nigel, Sat Feb 24 21:39:42 2007 UTC revision 63 by nigel, Sat Feb 24 21:40:03 2007 UTC
# Line 1  Line 1 
1  Compiling PCRE on non-Unix systems  Compiling PCRE on non-Unix systems
2  ----------------------------------  ----------------------------------
3    
4    See below for comments on Cygwin or MinGW usage.
5    
6  If you want to compile PCRE for a non-Unix system, note that it consists  If you want to compile PCRE for a non-Unix system, note that it consists
7  entirely of code written in Standard C, and so should compile successfully  entirely of code written in Standard C, and so should compile successfully
8  on any machine with a Standard C compiler and library, using normal compiling  on any machine with a Standard C compiler and library, using normal compiling
# Line 24  character tables. Line 26  character tables.
26    
27  (4) Compile maketables.c, get.c, study.c and pcre.c and link them all  (4) Compile maketables.c, get.c, study.c and pcre.c and link them all
28  together into an object library in whichever form your system keeps such  together into an object library in whichever form your system keeps such
29  libraries. This is the pcre library (chartables.c gets included by means of an  libraries. This is the pcre library (chartables.c is included by means of an
30  #include directive).  #include directive).
31    
32  (5) Similarly, compile pcreposix.c and link it as the pcreposix library.  (5) Similarly, compile pcreposix.c and link it as the pcreposix library.
# Line 34  pcre and pcreposix libraries when linkin Line 36  pcre and pcreposix libraries when linkin
36    
37  (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
38  that the output matches the corresponding testoutput files. You must use the  that the output matches the corresponding testoutput files. You must use the
39  -i option when checking testinput2.  -i option when checking testinput2. Note that the supplied files are in Unix
40    format, with just LF characters as line terminators. You may need to edit them
41    to change this if your system uses a different convention.
42    
43  If you have a system without "configure" but where you can use a Makefile, edit  If you have a system without "configure" but where you can use a Makefile, edit
44  Makefile.in to create Makefile, substituting suitable values for the variables  Makefile.in to create Makefile, substituting suitable values for the variables
45  at the head of the file.  at the head of the file.
46    
47  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
48  contributed by Paul.Sokolovsky@technologist.com. These environments are  contributed by Paul Sokolovsky. These environments are Mingw32
49  Mingw32 (http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and  (http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and CygWin
50  CygWin  (http://sourceware.cygnus.com/cygwin/). Paul comments:  (http://sourceware.cygnus.com/cygwin/). Paul comments:
51    
52    For CygWin, set CFLAGS=-mno-cygwin, and do 'make dll'. You'll get    For CygWin, set CFLAGS=-mno-cygwin, and do 'make dll'. You'll get
53    pcre.dll (containing pcreposix also), libpcre.dll.a, and dynamically    pcre.dll (containing pcreposix also), libpcre.dll.a, and dynamically
54    linked pgrep and pcretest. If you have /bin/sh, run RunTest (three    linked pgrep and pcretest. If you have /bin/sh, run RunTest (three
55    main test go ok, locale not supported).    main test go ok, locale not supported).
56    
57    Changes to do MinGW with autoconf 2.50 were supplied by Fred Cox
58    <sailorFred@yahoo.com>, who comments as follows:
59    
60      If you are using the PCRE DLL, the normal Unix style configure && make &&
61      make check && make install should just work[*]. If you want to statically
62      link against the .a file, you must define PCRE_STATIC before including
63      pcre.h, otherwise the pcre_malloc and pcre_free exported functions will be
64      declared __declspec(dllimport), with hilarious results.  See the configure.in
65      and pcretest.c for how it is done for the static test.
66    
67      Also, there will only be a libpcre.la, not a libpcreposix.la, as you
68      would expect from the Unix version. The single DLL includes the pcreposix
69      interface.
70    
71    [*] But note that the supplied test files are in Unix format, with just LF
72    characters as line terminators. You will have to edit them to change to CR LF
73    terminators.
74    
75    A script for building PCRE using Borland's C++ compiler for use with VPASCAL
76    was contributed by Alexander Tokarev. It is called makevp.bat.
77    
78    These are some further comments about Win32 builds from Mark Evans. They
79    were contributed before Fred Cox's changes were made, so it is possible that
80    they may no longer be relevant.
81    
82    The documentation for Win32 builds is a bit shy.  Under MSVC6 I
83    followed their instructions to the letter, but there were still
84    some things missing.
85    
86    (1) Must #define STATIC for entire project if linking statically.
87        (I see no reason to use DLLs for code this compact.)  This of
88        course is a project setting in MSVC under Preprocessor.
89    
90    (2) Missing some #ifdefs relating to the function pointers
91        pcre_malloc and pcre_free.  See my solution below.  (The stubs
92        may not be mandatory but they made me feel better.)
93    
94    =========================
95    #ifdef _WIN32
96    #include <malloc.h>
97    
98    void* malloc_stub(size_t N)
99    { return malloc(N); }
100    void free_stub(void* p)
101    { free(p); }
102    void *(*pcre_malloc)(size_t) = &malloc_stub;
103    void  (*pcre_free)(void *) = &free_stub;
104    
105    #else
106    
107    void *(*pcre_malloc)(size_t) = malloc;
108    void  (*pcre_free)(void *) = free;
109    
110    #endif
111    =========================
112    
113  ****  ****

Legend:
Removed from v.62  
changed lines
  Added in v.63

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12