Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java System.loadLibrary("m") fails on AIX 6.1

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.

like image 329
Chen Nam Sit Avatar asked Jan 22 '12 13:01

Chen Nam Sit


2 Answers

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.

like image 40
Lorinczy Zsigmond Avatar answered Oct 26 '22 00:10

Lorinczy Zsigmond


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'.

like image 199
Colm Smyth Avatar answered Oct 25 '22 23:10

Colm Smyth