您的位置:首页 > 其它

boost中regex使用时出现的问题

2016-05-04 21:31 295 查看
在使用到boost库中的regex的so文件中,如果出现如下错误:

undefined symbol: _ZN5boost9re_detail14verify_optionsEjNS_15regex_constants12_match_flagsE

说明在生成so文件时缺少引用regex的源文件,此时需要在makefile中或者编译时加上regex的库,然后重新编译

如果在重新编译时出现如下编译错误

 relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with
-fPIC

could
not read symbols: Bad value

此时说明引用的regex库在编译时并没有使用-fPIC选项,重新下载对应项目版本的boost库,最新的boost库下载地址:
https://sourceforge.net/projects/boost/files/boost/1.60.0/
下载完成后解压boost库,然后进入libs/regex/build目录

选择对应编译器的带有shared标识的makefile文件,如gcc-shared.mak

执行 make -f gcc-shared.mak

cd gcc/boost_regex-gcc-1_40_shared

ar cr target.a *.o

然后将target.a替换原来的regex.a库就可以了

如果原来是so文件,则用gcc/libboost_regex-gcc-1_40.so替换原来的regex.so(这个我没试,我原来的就是静态库)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  boost regex