在 OSX 10.5 上使用 LuaJava 时出现链接器错误
我在让这个库在我的 OSX 安装上运行时遇到了很多问题。 特别是,我想将它与 Java 1.6 VM 一起使用,但在编译它之后,我得到以下信息:
java -cp "luajava-1.1.jar" org.keplerproject.luajava.Console
Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/daniel/src/luajava- 1.1/libluajava-1.1.jnilib:
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1822)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1739)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at org.keplerproject.luajava.LuaState.<clinit>(LuaState.java:92)
at org.keplerproject.luajava.LuaStateFactory.newLuaState(LuaStateFactory.java:59)
at org.keplerproject.luajava.Console.main(Console.java:49)
I'm running OSX 10.5.8 with Lua 5.1.4 我还将我的 OSX 默认 VM 更改为 1.6.0:
/System/Library/Frameworks/JavaVM.framework/Home -> Versions/1.6.0/Home/
/System/Library/Frameworks/JavaVM.framework/Versions/Current -> 1.6.0/
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK -> 1.6.0/
我做错了什么?我注意到,当我使用 Java 1.5 时,一切都运行良好。但我不想要 1.5,我想要 1.6。
I'm having a bunch of problems getting this library to work on my OSX installation.
In particular, I'd like to use it with a Java 1.6 VM but after I compile it up I get the following:
java -cp "luajava-1.1.jar" org.keplerproject.luajava.Console
Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/daniel/src/luajava- 1.1/libluajava-1.1.jnilib:
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1822)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1739)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at org.keplerproject.luajava.LuaState.<clinit>(LuaState.java:92)
at org.keplerproject.luajava.LuaStateFactory.newLuaState(LuaStateFactory.java:59)
at org.keplerproject.luajava.Console.main(Console.java:49)
I'm running OSX 10.5.8 with Lua 5.1.4
I've also changed my OSX default VM to 1.6.0 as so:
/System/Library/Frameworks/JavaVM.framework/Home -> Versions/1.6.0/Home/
/System/Library/Frameworks/JavaVM.framework/Versions/Current -> 1.6.0/
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK -> 1.6.0/
What am I doing wrong? I notice when I use Java 1.5 everything works great. Except I don't want 1.5, I want 1.6.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可能是一条线索,来自 jnlua on luaforge,第 7 节。构建本机库:
我找不到任何其他直接参考,但考虑到您描述的症状,这似乎是一个合理的解释。 LuaJava 使用 LuaBinaries。
This may be a clue, from jnlua on luaforge, Section 7. Building the Native Library:
I couldn't find any other direct reference to this, but it seems a plausible explanation, given the symptoms you describe. LuaJava uses LuaBinaries.
问题是 Apple 仅在 Leopard 上发布了 64 位版本的 Java 6,这意味着所有 .jnilib 文件(以及相关的依赖项)都需要是/包含 64 位的。 Leopard 上的 Java 5 有 32 位和 64 位版本。更令人困惑的是,Snow Leopard 同时具有 32 位和 64 位版本的 Java 6。
因此,总结一下:
The problem is that Apple only released a 64 bit version of Java 6 on Leopard, which means that all .jnilib files (and associated dependencies) need to be/contain 64 bit. Java 5 on Leopard has both 32 and 64 bit versions. Even more confusing is the fact that Snow Leopard has both 32 and 64 bit versions of Java 6.
So, to summarize:
今天早上我按照 Joe Huges 的旧指示让它开始工作: http:// /retrovirus.com/incr/2005/08/building-luajava/(需要进行一些细微的修改)。我在 2007 年老式(32 位)MBP 上使用 10.6。
您描述的问题已通过将 libluajava-1.1.jnilib Java 库移动到 /Library/Java/Extensions/ 文件夹来解决。 -cp "luajava-1.1.jar" 标志将 jar 文件添加到您的路径中,但仍需要添加库。
I just got it to work this morning following these old directions by Joe Huges: http://retrovirus.com/incr/2005/08/building-luajava/ (Some slight modifications were necessary). I'm using 10.6 on a 2007-vintage (32 bit) MBP.
The problem you describe was solved by moving the libluajava-1.1.jnilib Java library to the /Library/Java/Extensions/ folder. The -cp "luajava-1.1.jar" flag adds the jar file to your path, but the library still needs to be added.
您需要将 luajava.jnilib 文件放在 /System/Library/Frameworks/JavaVM.framework/Library 目录中。
You need to put the luajava.jnilib file in your /System/Library/Frameworks/JavaVM.framework/Library directory.