简体   繁体   English

python加载静态库

[英]python load static library

i'm having a new problem here with loading dll's. 我在加载dll时遇到了新问题。 i didn't have any problem loading dll's with ".so", ".dll" extensions. 我在加载带有“ .so”,“。dll”扩展名的dll时没有任何问题。 now i'm having some issue with dll's with ".a" extension. 现在,我的扩展名为“ .a”的dll出现了问题。 its a static library. 它是一个静态库。 below is my code 下面是我的代码

Security_dll = ctypes.cdll.LoadLibrary("./staticlibraryname.a")

btw, my os env is a linux open suse. 顺便说一句,我的os env是一个linux open suse。 the exact error message i get when i try to do this is : 我尝试执行此操作时收到的确切错误消息是:

File "module3.py", line 3, in <module>
Security_dll = ctypes.cdll.LoadLibrary("./libSecurityProductionStaticlib.a")
File "/usr/lib64/python2.7/ctypes/__init__.py", line 440, in LoadLibrary
return self._dlltype(name)
File "/usr/lib64/python2.7/ctypes/__init__.py", line 362, in __init__
self._handle = _dlopen(self._name, mode)
OSError: ./libSecurityProductionStaticlib.a: invalid ELF header

You cannot load a static library into running code. 您不能将静态库加载到正在运行的代码中。 Only dynamically linked libraries (.so and .dll) can be loaded. 只能加载动态链接的库(.so和.dll)。 Static and dynamic libraries have different formats, properties, and purposes. 静态和动态库具有不同的格式,属性和用途。 Static libraries can be linked with other objects only at compile time, but not at run time. 静态库只能在编译时与其他对象链接,而不能在运行时与其他对象链接。 A dynamic library on Linux is essentially an ELF file without the main function. Linux上的动态库本质上是没有主要功能的ELF文件。 A static library is an archive of functions. 静态库是函数的存档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM