Build and use PCRE in windows

Building PCRE(older version) source code in windows environment is quite easy with CMake build system. Once you checkout the code from their SVN server using following command:
    svn co svn://vcs.exim.org/pcre/code/trunk pcre

Install the CMake build system and issue the following command from the “pcre” folder to build the visual studio project/solution files.
    cmake.exe .

Open the PCRE.sln file in visual studio and start compiling “pcre” project. It will create
a PCRE STATIC library file for linking it with other projects.

             image

I used sample source code from this StackOverflow link. Created an empty visual studio project and added this code and compiled it. Initially i faced with the linking error and it can be fixed with added a #define for PCRE_STATIC.

You need to define it before including pcre.h file.
    #define PCRE_STATIC 1
    #include <string>
    #include <iostream>
    #include “pcre.h”

You need to include either pcred.lib or pcre.lib for building the final binary.

Advertisements
This entry was posted in Regex, Windows, Windows VC++ and tagged , , . Bookmark the permalink.

One Response to Build and use PCRE in windows

  1. Pingback: Build and use PCRE in windows | d@n3n | Scoop.it

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s