没错,re::engine::RE2从来没有在 OS X 上编译过。但你可以让它编译。找到 cpan 目录。对我来说是~/.cpan/build/re-engine-RE2-0.13-BY20k3/。然后在其中更改两个 C++ 源文件。
$ diff -p re2_xs.cc.old re2_xs.cc
*** re2_xs.cc.old   2015-04-20 20:20:15.000000000 +0200
--- re2_xs.cc   2015-04-20 20:22:24.000000000 +0200
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 229,236 ****
      RE2 * ri = (RE2*) SvANY(rx)->pprivate;
      regexp * re = SvANY(rx);
-     re2::StringPiece res[re->nparens + 1];
-
  #ifdef RE2_DEBUG
      Perl_warner(aTHX_ packWARN(WARN_MISC), "RE2: Matching '%s' (%p, %p) against '%s'", stringarg, strbeg, stringarg, RX_WRAPPED(rx));
  #endif
--- 229,234 ----
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 241,246 ****
--- 239,246 ----
        return 0;
      }
+     re2::StringPiece *res = new re2::StringPiece[re->nparens + 1];
+
      bool ok = ri->Match(
              re2::StringPiece(strbeg, strend - strbeg),
              stringarg - strbeg,
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 250,255 ****
--- 250,256 ----
      /* Matching failed */
      if (!ok) {
+         delete [] res;
          return 0;
      }
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 266,271 ****
--- 267,274 ----
          }
      }
+     delete [] res;
+
      return 1;
  }
在那之后尝试编译会让你遇到一个tr1问题。
/usr/bin/clang -o obj/util/arena.o -xc++   -O3 -DHAVE_PTHREAD -pthread -Wno-sign-compare -c -I.    -DNDEBUG util/arena.cc
In file included from util/arena.cc:5:
./util/util.h:45:10: fatal error: 'tr1/unordered_set' file not found
我确信-DMakefile 有更简单的修复,但我更改了代码。
# diff -p re2/util/util.h.old re2/util/util.h
*** re2/util/util.h.old 2015-04-20 20:29:01.000000000 +0200
--- re2/util/util.h 2015-04-20 20:29:26.000000000 +0200
*************** using std::make_pair;
*** 42,49 ****
  #if defined(__GNUC__) && !defined(USE_CXX0X)
! #include <tr1/unordered_set>
! using std::tr1::unordered_set;
  #else
--- 42,51 ----
  #if defined(__GNUC__) && !defined(USE_CXX0X)
! //#include <tr1/unordered_set>
! //using std::tr1::unordered_set;
! #include <unordered_set>
! using std::unordered_set;
  #else
现在只是
make && make install
你现在re::engine::RE2可以在 OS X上使用了。