Re: Fwd: .so interdependencies

Paul Northug <[email protected]>
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
On Fri, Apr 16, 2010 at 4:45 AM, Anderson Lizardo
<[email protected]> wrote:
> [forgot to CC the mailing list]
>
>
> ---------- Forwarded message ----------
> From: Anderson Lizardo <[email protected]>
> Date: Fri, Apr 16, 2010 at 7:44 AM
> Subject: Re: [ctypes-users] .so interdependencies
> To: Paul Northug <[email protected]>
>
>
> On Fri, Apr 16, 2010 at 3:44 AM, Paul Northug <[email protected]> wrote:
>> I get an error:
>>
>> libmytest.so: undefined symbol: slamch_
>>
>> which is a function in a different library .so that is used by a
>> function in my library.
>>
>> They are both in LD_LIBRARY_PATH. Is there a way to resolve this? I
>> have the freedom of creating the library, if that helps, but I don't
>> know much about shared libraries and how the dependencies between
>> libraries get resolved. Did I build my .so correctly given that it
>> works fine in other C programs that use it?
>>
>> I have read one other post describing a similar problem but it didn't
>> seem to have gotten resolved.
>
> On that thread (?) I posted this example:
>
> libx11 = ctypes.CDLL("libX11.so.6", mode=ctypes.RTLD_GLOBAL)
>
> Does it work for you ? (replace libx11 with the library that contains
> the "slamch_" symbol, and put the line above your libmytest.so
> library.

Your suggestion worked, but before I loaded my .so with LoadLibrary, I
had to load in all the libraries that this particular .so depended on
one by one with RTLD_GLOBAL, which made me realize I had not built it
the correct way in the first place. So using something similar to
Michelle's suggestion, I did:

g++ -shared -o libmytest.so -L. -L(other lib paths) -lacml -lacml_mv
-l(a bunch of other libs) src/*.o

and I was able to load the library correctly. I am guessing that this
type of error would not occur if the original .so is properly linked
with all its dependencies and that they are all in LD_LIBRARY_PATH
(checking with 'ldd'). I think I need to better understand what a
shared library is before I use ctypes more.

Thanks,
Pål

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.