如何在python中导入静态库? [英] How to import static library in python?
本文介绍了如何在python中导入静态库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个静态库(liba.a),我想在python中使用它
I have a static library(liba.a) and i want to use it in python
但是 import
只能在python中导入动态库
but import
can only import dynamic library in python
如何在python中导入静态库?
how to import static library in python??
推荐答案
你不能这样做。您有两种选择:
You can't do this. You have two options:
-
将库重新编译为共享库。然后使用
ctypes
从动态加载的共享库中调用方法。
Recompile the library as a shared library. Then use
ctypes
to call methods from the dynamically-loaded shared library.
建立 Python扩展将Python接口暴露给共享库。
Build a Python Extension exposing a Python interface to the shared library.
这篇关于如何在python中导入静态库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文