c++ - RE2库的xcode5下编译问题
黄舟
黄舟 2017-04-17 11:14:07
[C++讨论组]

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的安装问题?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回复(1)
怪我咯

自问自答,这个问题已经解决了,之所以后面出错的原因是因为C11支持的原因。所以上面的patch也是有问题的。

如果你是homebrew用户,可以使用这个Formula替代默认的Formula:

https://github.com/ipfans/homebrew/blob/master/Library/Formula/re2.rb

Pull request已经提交了,也可以等待通过后即可brew update后安装即可。

如果手工修复,需要修改Makefile文件和libre2.symbols.darwin文件即可编译通过。修改方法参见git diff即可。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号