Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96676

Re: python how to load multiple C libraries

Path csiph.com!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <lac@openend.se>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'cc:addr :python-list': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'separately': 0.09; 'subject:python': 0.14; 'wed,': 0.15; 'argument.': 0.16; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'ctypes.': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'libs': 0.16; 'message- id:@fido.openend.se': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'this).': 0.16; 'laura': 0.18; 'load': 0.20; '2015': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'ctypes': 0.22; 'libraries': 0.22; 'see:': 0.22; 'sep': 0.22; "haven't": 0.24; "doesn't": 0.26; '(which': 0.26; 'loads': 0.29; 'once,': 0.29; 'received:se': 0.29; 'them?': 0.29; 'thread,': 0.29; 'cc:no real name:2**1': 0.29; 'knows': 0.32; 'anybody': 0.32; 'maybe': 0.33; 'problem': 0.33; 'url:python': 0.33; 'done,': 0.33; 'loading': 0.33; 'file': 0.34; 'problem.': 0.35; 'but': 0.36; 'should': 0.36; 'instead': 0.36; 'there': 0.36; 'url:org': 0.36; 'depends': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'wanted': 0.37; 'mean': 0.38; 'ever': 0.60; 'header:Message-Id:1': 0.61; 'first?': 0.84; 'header:In-reply-to:1': 0.84; 'url:ml': 0.84
To "chenchao@inhand.com.cn" <chenchao@inhand.com.cn>
cc python-list@python.org, lac@openend.se
From Laura Creighton <lac@openend.se>
Subject Re: python how to load multiple C libraries
In-reply-to <55F937D6.6040104@inhand.com.cn>
References <55F937D6.6040104@inhand.com.cn>
Comments In-reply-to "chenchao@inhand.com.cn" <chenchao@inhand.com.cn> message dated "Wed, 16 Sep 2015 17:35:18 +0800."
MIME-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-ID <17721.1442409221.1@fido>
Content-Transfer-Encoding quoted-printable
Date Wed, 16 Sep 2015 15:13:41 +0200
X-Greylist Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [82.96.5.2]); Wed, 16 Sep 2015 15:13:51 +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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.634.1442409253.8327.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1442409253 news.xs4all.nl 23782 [2001:888:2000:d::a6]:33518
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:96676

Show key headers only | View raw


In a message of Wed, 16 Sep 2015 17:35:18 +0800, "chenchao@inhand.com.cn" write
s:
>hi:
>I encountered a problem. I use ctypes load multiple C  libraries, but 
>the libraries have dependence each other.So, how can i load these 
>libraries. For example, I have two libraries:A、B, but A depends on B, B 
>depends on A. So how do I load them? Is there anybody know how to do it?

I don't know how to do this with ctypes (which doesn't mean it cannot be
done, just that I haven't ever wanted to do this). What happens if you
make a small file that loads both separately and loads that one first?

It may be that you can get what you want with by loading the first lib
RTLD_LAZY instead of RTLD_NOW.  see:
http://stackoverflow.com/questions/22591472/dyanamic-library-linking-by-rtld-lazy
see: this very old thread, maybe CTypes knows about it now.
http://osdir.com/ml/python.ctypes/2006-10/msg00029.html

But I have never tried.

These days I used cffi instead of ctypes.

If you use cffi https://pypi.python.org/pypi/cffi
there should not be any problem if you use ffi.set_source(), 
only once, but mentioning both libs in the libraries=[...] argument.

Laura


Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: python how to load multiple C libraries Laura Creighton <lac@openend.se> - 2015-09-16 15:13 +0200

csiph-web