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:
- 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.
- 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
- Rename PCRE. H. Generic to PCRE. H, and pcre_chartables.c.dist to pcre_chartables.c
cl -MD -DHAVE_CONFIG_H dftables.c
Generate dftables.exe
- Dftables.exe pcre_chartables.c (modified some comments and I don't know why)
- 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.
- 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")
- 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); |