Java System.loadLibrary(“m”) 在 AIX 6.1 上失败

发布于 2024-12-28 02:55:32 字数 671 浏览 7 评论 0原文

在 AIX 6.1 ppc64 上,为了加载 libm.a,我们的应用程序使用 System.loadLibrary("m")。 或者失败并显示错误消息

模块的幻数无效

根据 IBM 文档,当 32 位和 64 位二进制文​​件不匹配时,可能会发生这种情况。或者无论我们使用Java6(32位)还是Java6_64(64位)JVM,都会发生这种情况。 所以事实并非如此。

另一个可能的原因是 /usr/lib/libm.a 不是共享库。但我们就是在平台上找不到共享模式的libm.a来使用!

根据 Javadoc,在 System.loadLibrary("name") 中,“name”到真实库的映射是系统相关的。在大多数 Unix 系统上,它映射到 lib.so,而在 AIX 上,它映射到 lib.a ;请注意,在 AIX 上,.a 可以是混合的,即。它可以包含静态和共享对象、32 位和 64 位对象。我的问题是在 AIX 上找到共享模式 libm.a。

有人知道如何使用 System.loadLibrary("m") 加载 libm.a 吗?

聚苯乙烯 System.loadLibrary("m") 在我们测试过的大多数 UNIX 平台上都可以正常工作。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

灵芸 2025-01-04 02:55:32

您可以使用“dump -H”(AIX 相当于 ldd)来验证 libm.a 是否是共享库。 “file”命令应该区分 32 位和 64 位库,但 AIX 还支持在一个库中混合 32 位和 64 位。如果文件看起来没问题,请检查您的应用程序是否正在使用“truss”加载正确的 libm。

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

似狗非友 2025-01-04 02:55:32

在 AIX 上,发行版附带的共享对象被放置在 ar 归档中,例如在 32 位中,它是:

System.load("/usr/lib/libbsd.a(shr.o)")

在 64 位中:

System.load("/usr/lib/libbsd.a(shr_64.o)")

遗憾的是,libm.a 不包含任何共享对象(仅普通的 .o 对象模块),因此动态链接是不可能的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文