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:// 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.


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.

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

1 Response to Build and use PCRE in windows

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

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s