15

How to build Google RE2 for Windows? Somebody tried?

Maxim Masiutin
  • 3,991
  • 4
  • 55
  • 72
user536232
  • 645
  • 5
  • 18
  • 1
    What compiler are you using? RE2 will not build on MinGW because MinGW does not implement the full C++ standard. (and wchar_t stuff in particular) – Billy ONeal Apr 30 '11 at 02:29
  • @Billy ONeal, I use MSVC 2010. But can look for another one. – user536232 Apr 30 '11 at 02:33
  • 1
    @user: MSVC should work AFAIK. Google doesn't provide a makefile for it but you should just be able to build as you would any other C++ library. – Billy ONeal Apr 30 '11 at 02:47
  • 1
    @Billy ONeal, It misses some files, at least 'sys/time.h', 'sys/resource.h' and 'pthread.h' – user536232 Apr 30 '11 at 03:00
  • there is a [pthreads implementation](http://sourceware.org/pthreads-win32) for win32. For the rest, you could write your implementation in terms of win32 functions (possibly starting with dummy implementations for non-essential calls). – Rom1 May 02 '11 at 11:56
  • @Billy ONeal The one I downloaded from their site has `wchar_t`, as far as I remember (and there were "special" builds by someone not directly affiliated with MinGW earlier (at least 2-3 years ago), as I remember getting them just for that reason). Anyway, building Google C++ stuff on windows is painless only with MS compilers, using MinGW is always problematic (incl. cross-compiling with GCC on Linux -- see code.google.com/p/googletest/wiki/FAQ#Can_I_use_Google_Test_on_MinGW? (that's for GoogleTest, mentions cross-compiling)). – mlvljr May 09 '11 at 07:22
  • 1
    @mlvljr: It supports the datatype `wchar_t`, but it's missing some things like `char_traits`, `wstringstream`, etc. Perhaps that's changed since the last time I played with it, but AFAIK Boost.XPressive still is unable to build on that compiler because it's missing those bits. – Billy ONeal May 09 '11 at 23:20

5 Answers5

12

I made a fork available at http://code.google.com/p/re2win you can download the source as a .zip file and open the .vcproj file and compile in 'Release' mode.

unixman83
  • 9,421
  • 10
  • 68
  • 102
  • How to build it? What tools are required? – fithu Nov 27 '11 at 08:05
  • Great stuff. Will try it now. –  Jun 30 '12 at 18:46
  • I'm trying to get pyre2 working for Python. re2 is a prerequisite, i've built re2 for windows above in release mode but I'm unsure how to install it. I tried using the 'make' command using cygwin but i keep getting scope errors for the write func. Can anyone spell out how I get this installed for python? –  Nov 16 '16 at 11:25
4

UPDATE: found a Windows project which may or may not work better: https://code.google.com/p/re2win/

Old answer (non MSVC): https://groups.google.com/group/re2-dev/browse_thread/thread/0665d7e6693b4adb/54bae4e315a484e3

HaloWebMaster
  • 905
  • 6
  • 16
1

I bet it would build easily using Cygwin.

Ernest Friedman-Hill
  • 80,601
  • 10
  • 150
  • 186
0

Since September 2015 a CMakeLists.txt was added to RE2 repository. So now you can use CMake to generate files for Visual Studio and then build like a normal Visual Studio project. I have written a simple step-by-step tutorial on how to build and integrate RE2 in your C++ project for Windows. Tested for VS 13 and 15.

  • The link is broken. The correct link for the step by step tutorial is https://dfs-minded.com/build-integrate-re2-c-project-windows/ – Roobie Nuby May 12 '20 at 16:31
0

You can build RE2 for Windows with Microsoft Visual Studio by the Bazel build tool https://bazel.build/

  1. Get the latest version of RE2 by git clone https://github.com/google/re2.git
  2. Download Bazel Windows binary at https://github.com/bazelbuild/bazel/releases (scroll down and look for an .exe file)
  3. Put the Bazel binary in the root directory of RE2, or add a directory with the Bazel binary to %PATH%.
  4. Run the Visual Studio command prompt from the Start Menu, e.g., the the "x64 Native Tools Command Prompt"
  5. In the command prompt, go to your RE2 root folder, e.g. cd c:\gitrepos\re2
  6. Run bazel.exe build :all
  7. Bazel will create the subdirectoris bazel-bin, bazel-out, bazel-re2, bazel-testlogs.
  8. You will find the compiled RE2 binaries, i.e. the library and the test programs (.lib, .pdb, .exe) at bazel-bin
  9. Optionally, you may run test programs, e.g. regexp_benchmark.exe. You will see the output like that:
Search_Easy0_CachedDFA/8    10000000           105 ns/op      75.71 MB/s
Search_Easy0_CachedDFA/16   20000000           107 ns/op     148.31 MB/s
Search_Easy0_CachedDFA/32   20000000           121 ns/op     262.31 MB/s
Search_Easy0_CachedDFA/64   20000000           122 ns/op     523.80 MB/s
Search_Easy0_CachedDFA/128  20000000           120 ns/op    1061.91 MB/s
Search_Easy0_CachedDFA/256  20000000           122 ns/op    2081.69 MB/s
Search_Easy0_CachedDFA/512  10000000           185 ns/op    2760.31 MB/s
Search_Easy0_CachedDFA/1K   10000000           270 ns/op    3786.29 MB/s
Search_Easy0_CachedDFA/2K    5000000           409 ns/op    4995.25 MB/s
Search_Easy0_CachedDFA/4K    5000000           573 ns/op    7143.45 MB/s
Search_Easy0_CachedDFA/8K    1000000          1144 ns/op    7159.05 MB/s
Search_Easy0_CachedDFA/16K   1000000          1887 ns/op    8680.17 MB/s
Search_Easy0_CachedDFA/32K    500000          3620 ns/op    9049.65 MB/s
Search_Easy0_CachedDFA/64K    500000          7411 ns/op    8842.68 MB/s

etc...
Maxim Masiutin
  • 3,991
  • 4
  • 55
  • 72