简体   繁体   中英

python load static library

i'm having a new problem here with loading dll's. i didn't have any problem loading dll's with ".so", ".dll" extensions. now i'm having some issue with dll's with ".a" extension. its a static library. below is my code

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

btw, my os env is a 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. 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. A static library is an archive of functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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