📄 non-unix-use
字号:
Compiling PCRE on non-Unix systems----------------------------------See below for comments on Cygwin or MinGW and OpenVMS usage. I (Philip Hazel)have no knowledge of Windows or VMS sytems and how their libraries work. Theitems in the PCRE Makefile that relate to anything other than Unix-like systemshave been contributed by PCRE users. There are some other comments and files inthe Contrib directory on the ftp site that you may find useful. See ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ContribIf you want to compile PCRE for a non-Unix system (or perhaps, more strictly,for a system that does not support "configure" and "make" files), note thatthe basic PCRE library consists entirely of code written in Standard C, and soshould compile successfully on any system that has a Standard C compiler andlibrary. The C++ wrapper functions are a separate issue (see below).GENERIC INSTRUCTIONS FOR THE C LIBRARYThe following are generic comments about building PCRE. The interspersedindented commands are suggestions from Mark Tetrode as to which commands youmight 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 thatdefine HAVE_STRERROR and HAVE_MEMMOVE to define them as 1 rather than 0.Unfortunately, because of the way Unix autoconf works, the default setting hasto be 0. You may also want to make changes to other macros in config.h. Inparticular, if you want to force a specific value for newline, you can definethe NEWLINE macro. The default is to use '\n', thereby using whatever valueyour 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) Compile dftables.c as a stand-alone program, and then run it withthe single argument "pcre_chartables.c". This generates a set of standardcharacter tables and writes them to that file. rem Mark Tetrode's commands rem Compile & run cl -DSUPPORT_UTF8 -DSUPPORT_UCP dftables.c dftables.exe pcre_chartables.c(3) Compile the following source files: pcre_chartables.c pcre_compile.c pcre_config.c pcre_dfa_exec.c pcre_exec.c pcre_fullinfo.c pcre_get.c pcre_globals.c pcre_info.c pcre_maketables.c pcre_ord2utf8.c pcre_refcount.c pcre_study.c pcre_tables.c pcre_try_flipped.c pcre_ucp_searchfuncs.c pcre_valid_utf8.c pcre_version.c pcre_xclass.cand link them all together into an object library in whichever form your systemkeeps such libraries. This is the pcre C library. If your system has static andshared libraries, you may have to do this once for 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(4) Similarly, compile pcreposix.c and link it (on its own) as the pcreposixlibrary. 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(5) Compile the test program pcretest.c. This needs the functions in thepcre and pcreposix libraries when linking. rem Mark Tetrode's commands rem compile & link cl /F0x400000 pcretest.c pcre.lib pcreposix.lib(6) Run pcretest on the testinput files in the testdata directory, and checkthat the output matches the corresponding testoutput files. You must use the-i option when checking testinput2. Note that the supplied files are in Unixformat, with just LF characters as line terminators. You may need to edit themto change this if your system uses a 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\myoutput6Note that there are now three more tests (7, 8, 9) that did not exist when Markwrote those comments. The test the new pcre_dfa_exec() function.(7) If you want to use the pcregrep command, compile and link pcregrep.c; ituses only the basic PCRE library.THE C++ WRAPPER FUNCTIONSThe PCRE distribution now contains some C++ wrapper functions and tests,contributed by Google Inc. On a system that can use "configure" and "make",the functions are automatically built into a library called pcrecpp. It shouldbe straightforward to compile the .cc files manually on other systems. Thefiles called xxx_unittest.cc are test programs for each of the correspondingxxx.cc files.FURTHER REMARKSIf you have a system without "configure" but where you can use a Makefile, editMakefile.in to create Makefile, substituting suitable values for the variablesat the head of the file.Some help in building a Win32 DLL of PCRE in GnuWin32 environments wascontributed by Paul Sokolovsky. These environments are Mingw32(http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and CygWin(http://sourceware.cygnus.com/cygwin/). Paul comments: For CygWin, set CFLAGS=-mno-cygwin, and do 'make dll'. You'll get pcre.dll (containing pcreposix also), libpcre.dll.a, and dynamically linked pgrep and pcretest. If you have /bin/sh, run RunTest (three main test go ok, locale not supported).Changes to do MinGW with autoconf 2.50 were supplied by Fred Cox<sailorFred@yahoo.com>, who comments as follows: If you are using the PCRE DLL, the normal Unix style configure && make && make check && make install should just work[*]. If you want to statically link against the .a file, you must define PCRE_STATIC before including pcre.h, otherwise the pcre_malloc and pcre_free exported functions will be declared __declspec(dllimport), with hilarious results. See the configure.in and pcretest.c for how it is done for the static test. Also, there will only be a libpcre.la, not a libpcreposix.la, as you would expect from the Unix version. The single DLL includes the pcreposix interface.[*] But note that the supplied test files are in Unix format, with just LFcharacters as line terminators. You will have to edit them to change to CR LFterminators.A script for building PCRE using Borland's C++ compiler for use with VPASCALwas contributed by Alexander Tokarev. It is called makevp.bat.These are some further comments about Win32 builds from Mark Evans. Theywere contributed before Fred Cox's changes were made, so it is possible thatthey may no longer be relevant."The documentation for Win32 builds is a bit shy. Under MSVC6 Ifollowed their instructions to the letter, but there were stillsome things missing.(1) Must #define STATIC for entire project if linking statically. (I see no reason to use DLLs for code this compact.) This of course is a project setting in MSVC under Preprocessor.(2) Missing some #ifdefs relating to the function pointers pcre_malloc and pcre_free. See my solution below. (The stubs may not be mandatory but they made me feel better.)"=========================#ifdef _WIN32#include <malloc.h>void* malloc_stub(size_t N){ return malloc(N); }void free_stub(void* p){ free(p); }void *(*pcre_malloc)(size_t) = &malloc_stub;void (*pcre_free)(void *) = &free_stub;#elsevoid *(*pcre_malloc)(size_t) = malloc;void (*pcre_free)(void *) = free;#endif=========================BUILDING PCRE ON OPENVMSDan Mooney sent the following comments about building PCRE on OpenVMS. Theyrelate to an older version of PCRE that used fewer source files, so the exactcommands will need changing. See the current list of source files above."It was quite easy to compile and link the library. I don't have a formalmake file but the attached file [reproduced below] contains the OpenVMS DCLcommands I used to build the library. I had to add #definePOSIX_MALLOC_THRESHOLD 10 to pcre.h since it was not defined anywhere.The library was built on:O/S: HP OpenVMS v7.3-1Compiler: Compaq C v6.5-001-48BCDLinker: vA13-01The test results did not match 100% due to the issues you mention in yourdocumentation regarding isprint(), iscntrl(), isgraph() and ispunct(). Imodified some of the character tables temporarily and was able to get theresults to match. Tests using the fr locale did not match since I don't havethat locale loaded. The study size was always reported to be 3 less than thevalue in the standard test output files."=========================$! This DCL procedure builds PCRE on OpenVMS$!$! I followed the instructions in the non-unix-use file in the distribution.$!$ COMPILE == "CC/LIST/NOMEMBER_ALIGNMENT/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES$ COMPILE DFTABLES.C$ LINK/EXE=DFTABLES.EXE DFTABLES.OBJ$ RUN DFTABLES.EXE/OUTPUT=CHARTABLES.C$ COMPILE MAKETABLES.C$ COMPILE GET.C$ COMPILE STUDY.C$! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol$! did not seem to be defined anywhere.$! I edited pcre.h and added #DEFINE SUPPORT_UTF8 to enable UTF8 support.$ COMPILE PCRE.C$ LIB/CREATE PCRE MAKETABLES.OBJ, GET.OBJ, STUDY.OBJ, PCRE.OBJ$! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol$! did not seem to be defined anywhere.$ COMPILE PCREPOSIX.C$ LIB/CREATE PCREPOSIX PCREPOSIX.OBJ$ COMPILE PCRETEST.C$ LINK/EXE=PCRETEST.EXE PCRETEST.OBJ, PCRE/LIB, PCREPOSIX/LIB$! C programs that want access to command line arguments must be$! defined as a symbol$ PCRETEST :== "$ SYS$ROADSUSERS:[DMOONEY.REGEXP]PCRETEST.EXE"$! Arguments must be enclosed in quotes.$ PCRETEST "-C"$! Test results:$!$! The test results did not match 100%. The functions isprint(), iscntrl(),$! isgraph() and ispunct() on OpenVMS must not produce the same results$! as the system that built the test output files provided with the$! distribution.$!$! The study size did not match and was always 3 less on OpenVMS.$!$! Locale could not be set to fr$!=========================****
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -