[pcre-dev] Compiling a PCRE 8.32 library file for use with C…

トップ ページ
このメッセージを削除
著者: pcunite
日付:  
To: pcre-dev
題目: [pcre-dev] Compiling a PCRE 8.32 library file for use with C++ Builder
Hello,
I've been enjoying learning about and using PCRE. However, I've found the
documentation as it relates to the Borland C++ Builder compiler lacking and incorrect.
Below are corrections I would like added to the project if appropriate. Feel free
to edit in whatever way is necessary.

--------------------------------------------------------------------
How to build the PCRE 8.32 library for C++ Builder 2007 (CB2007) and higher.

Notes:
The XE versions of C++ Builder come with a RegularExpressionsCore
class which contain a version of TPerlRegEx. However, direct use
of the C PCRE library may be desirable.

The default makevp.bat, however, supplied with PCRE 8.32 builds a
version of PCRE that is not usable with any version of C++ Builder
because the compiler ships with an embedded version of PCRE, version
2.01 from 1998! If you want to use PCRE you'll need to rename the
functions (pcre_compile to pcre_compile_bcc, etc) or do as I have done
and just use the 16 bit versions. I'm using std::wstring everywhere
anyway. Since the embedded version of PCRE does not have the 16 bit
function names, there is no conflict.


Building PCRE using a C++ Builder static library project file (recommended).

1.
Rename or remove pcre.h, pcreposi.h, and pcreposix.h from your C++ Builder
original include path.

2.
Download PCRE 8.32 from pcre.org and extract to a directory.

3.
Rename pcre_chartables.c.dist to pcre_chartables.c, pcre.h.generic to pcre.h,
and config.h.generic to config.h.

4.
Edit pcre.h and pcre_config.c so that they include config.h.

5.
Edit config.h like so:
Comment out the following lines:
#define PACKAGE "pcre"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_NAME "PCRE"
#define PACKAGE_STRING "PCRE 8.32"
#define PACKAGE_TARNAME "pcre"
#define PACKAGE_URL ""
#define PACKAGE_VERSION "8.32"

Add the following lines:
#ifndef SUPPORT_UTF
#define SUPPORT_UTF 100 // any value is fine
#endif

#ifndef SUPPORT_UCP
#define SUPPORT_UCP 101 // any value is fine
#endif

#ifndef SUPPORT_UCP
#define SUPPORT_PCRE16 102 // any value is fine
#endif

#ifndef SUPPORT_UTF8
#define SUPPORT_UTF8 103 // any value is fine
#endif


6.
Build a C++ Builder project using the IDE. Go to File / New / Other and choose
Static Library. You can name it pcre.cbproj or whatever. Now set your paths by
going to Project / Options. Set the Include path. Do this from the "Base" option
to apply to both Release and Debug builds. Now add the following files to the project:

pcre.h
pcre16_byte_order.c
pcre16_chartables.c
pcre16_compile.c
pcre16_config.c
pcre16_dfa_exec.c
pcre16_exec.c
pcre16_fullinfo.c
pcre16_get.c
pcre16_globals.c
pcre16_maketables.c
pcre16_newline.c
pcre16_ord2utf16.c
pcre16_printint.c
pcre16_refcount.c
pcre16_string_utils.c
pcre16_study.c
pcre16_tables.c
pcre16_ucd.c
pcre16_utf16_utils.c
pcre16_valid_utf16.c
pcre16_version.c
pcre16_xclass.c

//Optional
pcre_version.c

7.
After compiling the .lib file, copy the .lib and header files to a project you want to
use PCRE with. Enjoy.


Optional ... Building PCRE using the makevp.bat file.
1.
Edit makevp_c.txt and remove "pcre_info.c" from the list. Rename the others to the 16 bit versions.

2.
Edit makevp_l.txt and remove "+pcre_info.obj &" from the list. Rename the others to the 16 bit versions.

3.
Edit makevp.bat and set the path to C++ Builder. Run makevp.bat.

--------------------------------------------------------------------