re2库是个正则库,最近重新装了下OSX10.9,需要重新安装。
下载最近的re2-20131024.tgz,需要打一个libc++冲突的patch解决c++11的问题:
util/util.h:
@@ -41,7 +41,7 @@
using std::swap;
using std::make_pair;
-#if defined(__GNUC__) && !defined(USE_CXX0X)
+#if defined(__GNUC__) && !defined(USE_CXX0X) && !defined(_LIBCPP_ABI_VERSION)
#include <tr1/unordered_set>
using std::tr1::unordered_set;
但是编译时仍会报错:
$ make install prefix=/usr/local/Cellar/re2/20131024
......
clang: warning: argument unused during compilation: '-pthread'
Undefined symbols for architecture x86_64:
"operator<<(std::ostream&, re2::StringPiece const&)", referenced from:
-exported_symbol[s_list] command line option
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [obj/so/libre2.so] Error 1
导致这个的具体原因是什么?如何才能正确解决RE2的安装问题?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
自问自答,这个问题已经解决了,之所以后面出错的原因是因为C11支持的原因。所以上面的patch也是有问题的。
如果手工修复,需要修改Makefile文件和libre2.symbols.darwin文件即可编译通过。修改方法参见git diff即可。