In a message of Thu, 17 Sep 2015 15:41:26 +0800, "chenc...@inhand.com.cn" write s: > So, I checked my ctypes source code, I found RTLD_LAZY defined in >dlfcn.h header file like this: >/* The MODE argument to `dlopen' contains one of the following: */ >#define RTLD_LAZY 0x00001 /* Lazy function call binding. */ >#define RTLD_NOW 0x00002 /* Immediate function call binding. */ >#define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */ >#define RTLD_NOLOAD 0x00004 /* Do not load the object. */ >#if 0 /* uClibc doesnt support these */ >#define RTLD_DEEPBIND 0x00008 /* Use deep binding. */ >#endif > >/* If the following bit is set in the MODE argument to `dlopen', > the symbols of the loaded object and its dependencies are made > visible as if the object were linked directly into the program. */ >#define RTLD_GLOBAL 0x00100 > >/* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL. > The implementation does this by default and so we can define the > value to zero. */ >#define RTLD_LOCAL 0 > >/* Do not delete object when closed. */ >#define RTLD_NODELETE 0x01000 >The first of all, I have added followed codes in function: >PyMODINIT_FUNC init_ctypes(void) {...} in _ctypes.c file. > > /* add RTLD_LAZY and RTLD_NOW definitions*/ > PyModule_AddObject(m, "RTLD_LAZY", PyInt_FromLong(RTLD_LAZY)); > PyModule_AddObject(m, "RTLD_NOW", PyInt_FromLong(RTLD_NOW)); > >So, Is there anybody know how the CDLL can accept mode flag:RTLD_LAZY?
It's a known open bug. https://bugs.python.org/issue20276 Some people who have really needed to get this to work with ctypes have modified the source for ctypes as discribed here: http://osdir.com/ml/python.ctypes/2006-10/msg00029.html I just stopped using ctypes and use cffi instead. https://cffi.readthedocs.org/en/latest/ Laura -- https://mail.python.org/mailman/listinfo/python-list