静态库(.lib)到Python项目 [英] Static library (.lib) to Python project
问题描述
是否可以将.lib库中的模块导入Python程序(简单的.dll)?
is it possible to import modules from .lib library to Python program (as simple as .dll)?
推荐答案
理论,是的在实践中,可能不是 - 当然不像DLL一样简单。静态库本质上只是对象文件的集合,需要一个完整的链接器来正确地解析它们可能包含的所有重定位引用。可能需要使用静态库并简单地链接其内容以形成一个共享库,但这将需要静态库已经被构建为与位置无关的代码(PIC),这是不能保证的。在理论上,没有理由完整的链接器将链接库不能在运行时完成,但实际上没有现成的代码来实现。您最好的真实选择可能是追踪图书馆的来源或共享版本。
In theory, yes; in practice, probably not -- and certainly not as simply as a DLL. Static libraries are essentially just collections of object files, and need a full linker to correctly resolve all relocation references they may contain. It might be possible to take your static library and simply link its contents to form a shared library, but that would require that the static library had been built as position independent code (PIC), which is not guaranteed. In theory there's no reason the work a full linker would do to link the library couldn't be done at runtime, but in practice there's no off-the-shelf code for doing so. Your best real option is probably to track down the source or a shared version of the library.
这篇关于静态库(.lib)到Python项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!