Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'modified': 0.05; 'bug.': 0.07; 'mask': 0.07; 'cc:addr:python-list': 0.09; 'closed.': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'zero.': 0.09; 'subject:python': 0.14; 'argument': 0.15; 'instead.': 0.15; 'thu,': 0.15; 'value.': 0.15; 'binding.': 0.16; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'cc:name:laura creighton': 0.16; 'doesnt': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'inverse': 0.16; 'message-id:@fido.openend.se': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'laura': 0.18; 'load': 0.20; 'all,': 0.20; '2015': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**2': 0.20; 'ctypes': 0.22; 'function:': 0.22; 'object.': 0.22; 'sep': 0.22; 'visible': 0.22; 'file.': 0.22; 'code,': 0.23; 'defined': 0.23; 'bit': 0.23; 'this:': 0.23; 'header': 0.24; 'url:bugs': 0.24; 'define': 0.27; 'followed': 0.27; 'function': 0.28; 'received:se': 0.29; 'symbols': 0.29; 'cc:no real name:2**1': 0.29; 'checked': 0.31; 'anybody': 0.32; 'source': 0.33; 'url:python': 0.33; 'open': 0.33; 'file': 0.34; 'add': 0.34; 'so,': 0.35; 'skip:> 10': 0.35; 'stopped': 0.35; 'needed': 0.36; 'there': 0.36; 'url:org': 0.36; 'loaded': 0.36; 'mode': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'charset:us-ascii': 0.37; 'delete': 0.38; 'skip:p 20': 0.38; 'url:en': 0.39; 'does': 0.39; 'some': 0.40; 'header:Message-Id:1': 0.61; 'default': 0.61; 'linked': 0.63; 'here:': 0.63; 'binding': 0.66; 'header:In-reply-to:1': 0.84; 'url:ml': 0.84; 'url:readthedocs': 0.84; '{...}': 0.84; 'url:latest': 0.91 To: "chenchao@inhand.com.cn" cc: python-list@python.org, Laura Creighton , lac@openend.se From: Laura Creighton Subject: Re: python how to load multiple C libraries In-reply-to: <55FA6EA6.1030405@inhand.com.cn> References: <55F937D6.6040104@inhand.com.cn> <201509161313.t8GDDfUM017723@fido.openend.se> <55FA6EA6.1030405@inhand.com.cn> Comments: In-reply-to "chenchao@inhand.com.cn" message dated "Thu, 17 Sep 2015 15:41:26 +0800." MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32214.1442482719.1@fido> Content-Transfer-Encoding: quoted-printable Date: Thu, 17 Sep 2015 11:38:39 +0200 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [82.96.5.2]); Thu, 17 Sep 2015 11:38:46 +0200 (CEST) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442482952 news.xs4all.nl 23865 [2001:888:2000:d::a6]:37559 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96756 In a message of Thu, 17 Sep 2015 15:41:26 +0800, "chenchao@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