Python 官方文档:入门教程 => 点击学习
这篇文章主要介绍“python使用ctypes调用第三方库时出现undefined symbol错误怎么解决”,在日常操作中,相信很多人在Python使用ctypes调用第三方库时出现undefined symbol错误
这篇文章主要介绍“python使用ctypes调用第三方库时出现undefined symbol错误怎么解决”,在日常操作中,相信很多人在Python使用ctypes调用第三方库时出现undefined symbol错误怎么解决问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”python使用ctypes调用第三方库时出现undefined symbol错误怎么解决”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
在使用python 中使用中调用第三方so库时
import ctypescpp = ctypes.CDLL('./detector.so')
出现如下错误:
Traceback (most recent call last):
File “detection.py”, line 143, in
face_detection(image_path)
File “detection.py”, line 52, in face_detection
cpp = ctypes.CDLL(’./detector.so’)
File “/usr/lib/python3.8/ctypes/init.py”, line 373, in init
self._handle = _dlopen(self._name, mode)
OSError: ./detector.so: undefined symbol: __powf_finite
这是由于未定义__powf_finite引起的。
file detector.so
输出:
detector.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=8ac2d2c5490394447e21cf383f1428d8ad70be7a, with debug_info, not stripped
发现平台是没有问题的。
ldd -r detector.so
输出如下:
确实存在 undefined symbol: __powf_finite (./detector.so) 等问题,
使用以下命令来查找在c++代码中的位置
c++filt __powf_finite
最后面发现是我c++代码的问题,我在c++代码中又引用了第三方库.a文件,是.a文件的问题,这个文件是以前的老代码生成的,自己重新编译源码生成新的 .a文件就可以解决了。
到此,关于“python使用ctypes调用第三方库时出现undefined symbol错误怎么解决”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注编程网网站,小编会继续努力为大家带来更多实用的文章!
--结束END--
本文标题: python使用ctypes调用第三方库时出现undefined symbol错误怎么解决
本文链接: https://www.lsjlt.com/news/349393.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0