Re: Interface to a dynamic lib which loads other dynamiclibs [SEC=UNCLASSIFIED]
"Andrew MacIntyre" <[email protected]> Tue, 19 Oct 2010 16:44:19 +1100
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
> From: Georg Holzmann [mailto:[email protected]] > I try to use a dynamic library (slv2) in python, which is actually a > host for plugins (lv2 audio plugins, http://lv2plug.in/). > That means slv2 loads other dynamic libraries (= plugins) at runtime and > I want to be able to call functions from those plugins. > > The basic interface to slv2 works as it should, but as soon as I want to > instanciate some plugins, I get the following problem with ctypes: > > AttributeError: /usr/lib/libslv2.so.9: undefined symbol: > slv2_instance_activate > > because the symbol slv2_instance_activate is not in the slv2 library. > > I also tried to additionally load the plugin with ctypes: > ctypes.CDLL("/usr/lib/lv2/mypluginname.so", mode=ctypes.RTLD_GLOBAL) > but that also did not work. > > So my question: > Is it possible to interface such complicated libraries with ctypes ? (or > should I use something else) > How should this be done ? I was intrigued by your query, and had a look at the SLV2 source - the authors have made a decision that assumes that all users of SLV2 will have some compiled interface to the library, as a number of documented API functions only get compiled as part of the host interface (slv2_instance_activate() among them). See the "ifndef LIBSLV2_SOURCE" section of slv2/plugininstance.h in the SLV2 source... You have several choices that I can see: - build a private version of SLV2 modified to includes all the symbols in the library (and doesn't expect them to be built them into a host interface); - use the SWIG interface supplied in the SLV2 source (if you can build it or find a pre-built version to match your SLV2 library version); - write your own Python interface to SLV2 in C; - write a wrapper library that includes the "host only" functions and forwards the rest to the real SLV2 library, so its all ctypes loadable from one library; - become familiar enough with ctypes and the SLV2 headers to implement the "missing" functions with ctypes - you will need to understand struct & pointer manipulation and how to create function pointers. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: [email protected] http://www.acma.gov.au/ NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. This message has been content scanned by the Axway MailGate. MailGate uses policy enforcement to scan for known viruses, spam, undesirable content and malicious code. For more information on Axway products please visit www.axway.com. ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev