解决运行tfrecords的错误 arrow_cc.so: undefined symbol: inflateInit2_


今天用到一个python的包tfrecords,运行的时候遇到了错误

ImportError: /root/anaconda3/envs/ai/lib/python3.8/site-packages/tfrecords/lib/arrow_cc.so: undefined symbol: inflateInit2_

看情况是在我的环境中,arrow_cc.so 依赖于 zlib 库中的 inflateInit2_ 函数,但它可能加载了错误版本的 zlib。于是进行排查。

1.检查arrow_cc.so的动态链接

运行下面的命令,发现arrow_cc.so 动态链接的 libz.so 未正确加载

ldd /root/anaconda3/envs/ai/lib/python3.8/site-packages/tfrecords/lib/arrow_cc.so

#输出:
        linux-vdso.so.1 (0x00007ffe9697b000)
        libpython3.8.so.1.0 => /lib/libpython3.8.so.1.0 (0x00007768055e1000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007768053b5000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007768052ce000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007768052ae000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000776805086000)
        /lib64/ld-linux-x86-64.so.2 (0x00007768080ad000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x000077680507f000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x000077680507a000)
        libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x0000776805075000)

2.检查 zlib 是否正确安装

运行以下命令,检查系统是否安装了 libz.so

ls -l /lib/x86_64-linux-gnu/libz.so*

输出:
lrwxrwxrwx 1 root root     14 Jan  8 02:42 /lib/x86_64-linux-gnu/libz.so.1 -> libz.so.1.2.11
-rw-r--r-- 1 root root 108936 Jan  8 02:42 /lib/x86_64-linux-gnu/libz.so.1.2.11

3.链接到系统的 zlib

使用 LD_PRELOAD 强制加载系统的 libz.so,就可以运行了

export LD_PRELOAD=/lib/x86_64-linux-gnu/libz.so.1
IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x80): undefined reference to `deflate' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateCompressor::~WebSocketPerMessageDeflateCompressor()': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x3a0): undefined reference to `deflateEnd' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateCompressor::init(unsigned char, bool)': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x3f0): undefined reference to `deflateInit2_' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateCompressor::compress(ix::IXWebSocketSendData const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x5e0): undefined reference to `deflate' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateDecompressor::~WebSocketPerMessageDeflateDecompressor()': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0xa94): undefined reference to `inflateEnd' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateDecompressor::init(unsigned char, bool)': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0xad0): undefined reference to `inflateInit2_' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateDecompressor::decompress(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0xc1c): undefined reference to `inflate' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `bool ix::WebSocketPerMessageDeflateCompressor::compressData<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<unsigned char, std::allocator<unsigned char> >&) [clone .part.0]': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0xd4c): undefined reference to `deflate'以上错误如何解决
10-31
/usr/bin/ld: CMakeFiles/metaio.dir/metaUtils.cxx.o: in function `vtkmetaio::MET_UncompressStream(std::basic_ifstream<char, std::char_traits<char> >*, long, unsigned char*, long, long, vtkmetaio::MET_CompressionTable*)': metaUtils.cxx:(.text+0x19cc): undefined reference to `vtkzlib_inflateInit2_' /usr/bin/ld: metaUtils.cxx:(.text+0x1da2): undefined reference to `vtkzlib_inflate' /usr/bin/ld: CMakeFiles/metaio.dir/metaUtils.cxx.o: in function `vtkmetaio::MET_PerformCompression(unsigned char const*, long, long*, int)': metaUtils.cxx:(.text+0x20e8): undefined reference to `vtkzlib_deflateInit_' /usr/bin/ld: metaUtils.cxx:(.text+0x21a5): undefined reference to `vtkzlib_deflate' /usr/bin/ld: metaUtils.cxx:(.text+0x229a): undefined reference to `vtkzlib_deflateEnd' /usr/bin/ld: CMakeFiles/metaio.dir/metaUtils.cxx.o: in function `vtkmetaio::MET_PerformUncompression(unsigned char const*, long, unsigned char*, long)': metaUtils.cxx:(.text+0x22ff): undefined reference to `vtkzlib_inflateInit2_' /usr/bin/ld: metaUtils.cxx:(.text+0x23c3): undefined reference to `vtkzlib_inflate' /usr/bin/ld: metaUtils.cxx:(.text+0x244a): undefined reference to `vtkzlib_inflateEnd' /usr/bin/ld: CMakeFiles/metaio.dir/metaImage.cxx.o: in function `vtkmetaio::MetaImage::Clear()': metaImage.cxx:(.text+0x1e7c): undefined reference to `vtkzlib_inflateEnd' /usr/bin/ld: CMakeFiles/metaio.dir/metaImage.cxx.o: in function `vtkmetaio::MetaImage::M_ResetValues()': metaImage.cxx:(.text+0x6f31): undefined reference to `vtkzlib_inflateEnd'
最新发布
11-07
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值