我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用ctypes.RTLD_LOCAL。
def __init__(self): self.RTLD_LAZY = 0 # not supported anyway by ctypes self.RTLD_NOW = 0 self.RTLD_GLOBAL = ctypes.RTLD_GLOBAL self.RTLD_LOCAL = ctypes.RTLD_LOCAL
def SciterAPI(): """Bind Sciter API.""" if hasattr(SciterAPI, "_api"): return SciterAPI._api scdll = None import ctypes if SCITER_WIN: # load 4.x version by default try: scdll = ctypes.WinDLL(SCITER_DLL_NAME) except OSError: # try to find 3.x version try: dllname = "sciter64" if sys.maxsize > 2**32 else "sciter32" scdll = ctypes.WinDLL(dllname) except OSError: pass else: # same behavior for OSX & Linux import ctypes.util sclib = ctypes.util.find_library(SCITER_DLL_NAME) if not sclib: # try LD_LIBRARY_PATH def find_in_path(dllname, envname): import os if envname in os.environ: for directory in os.environ[envname].split(os.pathsep): fname = os.path.join(directory, dllname) if os.path.isfile(fname): return fname return None sclib = find_in_path(SCITER_DLL_NAME + SCITER_DLL_EXT, 'DYLD_LIBRARY_PATH' if SCITER_OSX else 'LD_LIBRARY_PATH') if not sclib: # last chance: try to load .so sclib = SCITER_DLL_NAME + SCITER_DLL_EXT try: scdll = ctypes.CDLL(sclib, ctypes.RTLD_LOCAL) except OSError: pass if not scdll: raise ImportError(SCITER_LOAD_ERROR) scdll.SciterAPI.restype = POINTER(ISciterAPI) SciterAPI._api = scdll.SciterAPI().contents return SciterAPI._api # end