Andy Stubbs on Wed, 20 May 1998 15:19:21 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
shared libraries: namespace problem / an unmoveable object meets an irresistable force / Java bindings for PARI |
Hi, I've been experiencing a rather intractible problem that I hope someone can explain. I'm surprised nobody has had this problem before (unless I'm being really dense): when both libpari.so and libc.so are in memory as shared libraries, _any_ reference to pari's err() function (including references made internally by libpari.so) is passed to libc's err() function... so the kind of error caused by flisexpr("2+[2]") typically results in: myapp: Scalar: No such file or directory bash:~$ echo $? 100 This is not exactly desirable behaviour... I tried to solve it using dlopen(), but still got nowhere. I have a work-around; basically I patched PARI so that every instance of err() was replaced by pari_err(), but this is _far_ from being a good solution. If someone who knows something about shared libraries (specifically on Linux 2.0.30, but _any_ hints would be a bonus) can please tell me how to make sure that pari's err() function is called instead of libc's then I'd be extremely grateful. How did I bump into this problem? Well, I notice from the UserGuide that there seem to be no Java bindings for PARI... Seeing a gap in the market I decided to corner a niche and write my own ;) The current status is 'too soon to tell', but it contains a few cute features and is quite usable. Most of the low-level interface exists (I always love the low level stuff), but the JNI layer mapping Java functions to pari routines is very spartan at the moment, and, due to my rather ad-hoc approach, the top layer of Java Objects is also likely to change radically. Here's a little taster of a fragment of code, if anyone's interested: PariVariable x; /* x is a PARI variable */ PariGen y; /* y is a generic PARI GEN object */ x = new PariVariable( "t" ); /* just to confuse everyone */ /* actually, x.polx() below can be shortened to just x */ y = pMath.gsqr( pMath.gadd( x.polx(), x.polun() ) ); /* t^2 + 2*t + 1 + t = t^2 + 3*t + 1 */ System.out.println( y + " + " + x + " = " + pMath.gadd(x,y) ); /* d(t^2 + 2*t + 1)/dt = 2*t + 2 */ System.out.println( "d(" +y + ")/d" + x + " = " + pMath.deriv(y,x) ); y = null; /* space on PARI stack will also be cleared */ But, this aside, I hope someone can shed light on my problem with shared libraries... thanks, Andy --------------------------------------------------------- Andy Stubbs +44 151 794 4045 agstubbs@liverpool.ac.uk