How to build Google RE2 for Windows? Somebody tried?
-
1What 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 Answers
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.

- 9,421
- 10
- 68
- 102
-
-
-
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
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

- 905
- 6
- 16
-
1
-
-
re2win does sure work but does anyone know of a more up to date windows port? – Alexander Theißen Aug 07 '15 at 21:44
I bet it would build easily using Cygwin.

- 80,601
- 10
- 150
- 186
-
11I wouldn't exactly call Cygwin "on windows" though, just as Wine isn't "on Unix". – Billy ONeal Apr 30 '11 at 02:24
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.

- 39
- 1
-
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
You can build RE2 for Windows with Microsoft Visual Studio by the Bazel build tool https://bazel.build/
- Get the latest version of RE2 by
git clone https://github.com/google/re2.git
- Download Bazel Windows binary at https://github.com/bazelbuild/bazel/releases (scroll down and look for an .exe file)
- Put the Bazel binary in the root directory of RE2, or add a directory with the Bazel binary to %PATH%.
- Run the Visual Studio command prompt from the Start Menu, e.g., the the "x64 Native Tools Command Prompt"
- In the command prompt, go to your RE2 root folder, e.g.
cd c:\gitrepos\re2
- Run
bazel.exe build :all
- Bazel will create the subdirectoris
bazel-bin
,bazel-out
,bazel-re2
,bazel-testlogs
. - You will find the compiled RE2 binaries, i.e. the library and the test programs (.lib, .pdb, .exe) at
bazel-bin
- 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...

- 3,991
- 4
- 55
- 72