Compile PCRE 8.13 on Windows platform cl.exe

Source: Internet
Author: User

Recently, a project developed on the Windows platform requires regular expressions. Of course, you can implement a Regexp by yourself, but it is too painful and technically unavailable. Therefore, I have given priority to the open source library. PCRE is a well-known library. Compiling in Linux is a common routine, but it is a little troublesome in win.

Refer to the topic "VC compilation PCRE memo" by tombkeeper. The procedure is as follows:

  1. Download the latest PCRE: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.zip (ZIP/tar.gz/tar.bz2 three formats choose one, Windows generally use zip), and unzip.
  2. Rename config. H. Generic to config. H. This is the generic configuration file. You need to modify the pre-compilation according to the specific environment.
    Change have_bcopy 1 to 0, change have_inttypes_h 1 to 0, and change have_stdint_h 1 to 0.
    If this parameter is not modified, an error is reported in the following steps for compiling dftables:

     

    Pcre_internal.h (198): Fatal error c1083: cannot open include file: 'inttypes. H': no such file or directory

  3. Rename PCRE. H. Generic to PCRE. H, and pcre_chartables.c.dist to pcre_chartables.c
  4. cl -MD -DHAVE_CONFIG_H dftables.cGenerate dftables.exe
  5. Dftables.exe pcre_chartables.c (modified some comments and I don't know why)
  6. CL-O1-MD-dhave_config_h-C Release-O1-MD-dhave_config_h-C Release-O1-MD-dhave_config_h-C pcre_config.ccl-O1-MD-dhave_config_h-C Release-O1- MD-dhave_config_h-C Release-O1-MD-dhave_config_h-C Release-O1-MD-dhave_config_h-C Release-O1-MD-dhave_config_h-C Release-O1-MD-dhave_config_h- c pcre_info.ccl-O1-MD-dhave_config_h-C Release-O1-MD-dhave_config_h-C Release-O1-MD-dhave_config_h-C Release-O1-MD-dhave_config_h-C Release-O1 -MD-dhave_config_h-C Release-O1-MD-dhave_config_h-C Release-O1-MD-dhave_config_h-C Release-O1-MD-dhave_config_h-C Release-O1-MD-dhave_config_h -C pcre_valid_utf8.ccl-O1-MD-dhave_config_h-C pcre_version.ccl-O1-MD-dhave_config_h-C pcre_xclass.clib-out: PCRE. lib pcre_chartables.obj pcre_compile.obj pcre_config.obj export pcre_exec.obj pcre_fullinfo.obj pcre_get.obj pcre_globals.obj pcre_info.obj pcre_maketables.obj pcre_newline.w.
    Pcre_refcount.obj pcre_study.obj pcre_tables.obj pcre_try_flipped.obj pcre_ucd.obj generated pcre_version.obj pcre_xclass.obj is the PCRE. Lib file we need.
    Note: If you want to compile the PCRE of the debug version. lib. replace-MDD with-MD. Otherwise, "msvcrtd. lib (cinitexe. OBJ): Warning lnk4098: Default library "msvcrt. lib.
  7. Copy PCRE. h and PCRE. lib to the directory of our own project, and add the following code at the top of the source code:
    #include "pcre.h"
    #pragma comment(lib,"pcre.lib")
  8. Use the following code to test:

     

    version= pcre_version();wchar_t
    *shit = (wchar_t
    *)malloc(strlen(version));MultiByteToWideChar(CP_ACP,0,version,-1,shit,wcslen(shit));MessageBox(hWnd,shit,shit,MB_OK);

     

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.