Manual PCRE compilation on Windows

Source: Internet
Author: User

Rename config. H. Generic to config. h.
Set the have_bcopy parameter to 0 (because the Windows platform does not have the bcopy () function)
Rename PCRE. H. Generic to PCRE. h.
Rename pcre_chartables.c.dist to pcre_chartables.c.
Compile dftables. C to an executable file. Add the-dhave_config_h parameter to import the settings in the config. h file.
/* Rename pcre_chartables.c.dist to pcre_chartables.c */
Run the compiled Executable File dftables.exe. The parameter is pcre_chartables.c.
Dftables.exe pcre_chartables.c
Create a project, including the following files, and compile it into a lib file.
Pcre_internal.h
UCP. h
Ucpinternal. h
Ucptable. h
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_newline.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.c

In this way, the libpcre. A file can be generated (VC and BCC generate PCRE. Lib, Which is similar)

2. Use the generated libpcre. A (static Link Library)

Add:

# Define pcre_static // enable the support for the static link library (you must add this row; otherwise, the static Link Library cannot be used)
# Include "PCRE. H" // PCRE header file
And add libpcre. A to the project, and then you can use the PCRE function in the program :)

Add/MT as the compilation option, and pre-compile a non-header file.

3. Use the generated libpcre-0.dll and libpcre. dll. A (Dynamic Link Library)

Add:

# Include "PCRE. H" // PCRE header file

And add libpcre. dll. A to the project, and then you can use the PCRE function in the program :)

========================================================== ==========================================================

The batchcompute solution under the command line. If the command line has been downloaded, you do not need to use the first line.

Goto start

First, make sure that the Console environment includes:
1. vc6 command line compiling environment
2XX wget.exeappsunzip.exeeclipsed.exe+mv.exe
Run the batch file to obtain the VC version of PCR. Lib.

: Start
Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.zip
Unzip pcre-7.7.zip
CD pcre-7.7
Sed-e "s/# define have_bcopy 1/# define have_bcopy 0/G" config. H. Generic> config. h
Mv pcre. H. Generic PCRE. h
MV pcre_chartables.c.dist pcre_chartables.c
CL-MD-dhave_config_h dftables. c
Dftables.exe pcre_chartables.c
CL-O1-MD-dhave_config_h-C pcre_chartables.c
CL-O1-MD-dhave_config_h-C pcre_compile.c
CL-O1-MD-dhave_config_h-C pcre_config.c
CL-O1-MD-dhave_config_h-C pcre_dfa_exec.c
CL-O1-MD-dhave_config_h-C pcre_exec.c
CL-O1-MD-dhave_config_h-C pcre_fullinfo.c
CL-O1-MD-dhave_config_h-C pcre_get.c
CL-O1-MD-dhave_config_h-C pcre_globals.c
CL-O1-MD-dhave_config_h-C pcre_info.c
CL-O1-MD-dhave_config_h-C pcre_maketables.c
CL-O1-MD-dhave_config_h-C pcre_newline.c
CL-O1-MD-dhave_config_h-C pcre_ord2utf8.c
CL-O1-MD-dhave_config_h-C pcre_refcount.c
CL-O1-MD-dhave_config_h-C pcre_study.c
CL-O1-MD-dhave_config_h-C pcre_tables.c
CL-O1-MD-dhave_config_h-C pcre_try_flipped.c
CL-O1-MD-dhave_config_h-C pcre_ucp_searchfuncs.c
CL-O1-MD-dhave_config_h-C pcre_valid_utf8.c
CL-O1-MD-dhave_config_h-C pcre_version.c
CL-O1-MD-dhave_config_h-C pcre_xclass.c
Lib-out: libpcr. Lib pcre_chartables.obj pcre_compile.obj pcre_config.obj running pcre_exec.obj running pcre_get.obj pcre_globals.obj pcre_info.obj running without running pcre_tables.obj
Pcre_try_flipped.obj pcre_ucp_searchfuncs.obj pcre_valid_utf8.obj pcre_version.obj pcre_xclass.obj

In this way, the PCRE. H + libpcr. Lib

========================================================== ==============================================

Recently, I used VC to compile her source code. In fact, the process is very simple, as follows:

1. rename some source files
Config. H. Generic is renamed to config. H (note the configuration in it)
Change PCRE. H. Generic to PCRE. h.
Pcre_chartables.c.dist is renamed pcre_chartables.c

2. Establish a VC Project
Create a vc dll project and remove the original inclusion File
Add all PCRE _ *. c In the PCRE. Do not add any "_" after the PCRE, or ". cc" with the suffix
You can refer to the above. And the. h file is also required.

3. Modify Project Settings

Add the project precompiled macro have_config_h.
Do not use pre-compiled headers not using precompiled headers
Compile option Add/mt

OK to complete the above three steps, you can compile on VC.

4. Compilation result
You only need to compile the. dll. Lib file and the PCRE. h file in the source code directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.