On AIX 6.1 ppc64, in order to load libm.a, our application uses the System.loadLibrary("m")
.
Or it fails with an error message
the module has invalid magic number
According to IBM documentation, this can happen when there is a mismatch between 32 bits and 64 bits binaries. Or this happens whether we use Java6 (32 bits) or Java6_64 (64 bits) JVM. So it is NOT the case.
Another possible causes is /usr/lib/libm.a
is NOT a shared library. But we just can't find a shared mode libm.a
on the platform to use!
Acccdoring to Javadoc, in System.loadLibrary("name") , the mapping of "name" on to a real library is system dependent. On most Unix system, it is mapped to lib.so, while on AIX, it is mapped on to lib.a ; Note that on AIX, .a can be hybrid, ie. it can contain both static and shared object, 32 bits as well as 64 bits object. My problem is find a shared mode libm.a on AIX.
Does anybody know how to use System.loadLibrary("m")
to load a libm.a
?
P.S
System.loadLibrary("m")
works fine on most UNIX platforms we have tested.
On AIX, the shared objects that come with the distribution are placed into ar
-archives, for example in 32-bit, it is:
System.load("/usr/lib/libbsd.a(shr.o)")
In 64-bit:
System.load("/usr/lib/libbsd.a(shr_64.o)")
Sadly, libm.a
doesn't contain any shared objects (only ordinary .o
object modules), so dynamic linking is not possible.
You can use 'dump -H' (AIX equivalent of ldd) to verify that libm.a is a shared library. The 'file' command should distinguish 32- and 64-bit libraries, but AIX also supports hybrid 32 and 64-bit in one library. If the file looks ok, check that your apps is loading the right libm using 'truss'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With