Monday, July 6, 2015

building PCRE on visual studio

Problem

Well, actually pcre library uses cmake & builds trivial. But I need some quick instruction for myself - so, let it be here - how to build pcre as static library with static runtime.


Action

1) Go to http://www.pcre.org/
find something like that:
'You can download the current releases of the PCRE and PCRE2 libraries from their official home via anonymous FTP:' ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
Go to this FTP and take pcre sources, for example: pcre-8.37.zip
Download & unpack.

2) for debug version:
- open cmd.exe or far manager, go to directory with sources
- create directory '_build_x64_static_debug_mtd', go to it
- exec: cmake .. -G "Visual Studio 12 2013 Win64"
now in this directory will a lot of files, and one of them must be PCRE.sln
- open PCRE.sln
- select target architecture, mode, select 8 projects (which names is lowercase) in 'solution explorer' and set everywhere /MTd instead of /MDd
- build solution

2) for release version:
- open cmd.exe or far manager, go to directory with sources
- create directory '_build_x64_static_release_mt', go to it
- exec: cmake .. -G "Visual Studio 12 2013 Win64"
now in this directory will a lot of directories, and one of file must be PCRE.sln
- open PCRE.sln
- select target architecture, mode, select 8 projects (which names is lowercase) in 'solution explorer' and set everywhere /MT instead of /MD
- build solution

3) If you want use pcre ONLY as static library, you can add '#define PCRE_STATIC' into pcre.h before the first occurrence of the PCRE_STATIC.

4) I prefer move pcre.h to another directory, bcs when you include this header, extra files from this directory can be also included as side-effect, and lead to problems. So I put it like that:
pcre-8.37\_build_x64_static_release_mt\include\pcre.h
pcre-8.37\_build_x64_static_debug_mtd\include\pcre.h


1 comment: