我正在寫一個基於java的遊戲,試圖使用Slick2D。然而,當我嘗試運行測試應用(下),我得到這個:Slick2D測試應用程序導致UnsatisfiedLinkException:錯誤ELFCLASS
OpenJDK Server VM warning: You have loaded library /home/andrzej/Programming/Java/HeroesOfZether/lib/lwjgl/native/linux/liblwjgl.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/andrzej/Programming/Java/HeroesOfZether/lib/lwjgl/native/linux/liblwjgl.so: /home/andrzej/Programming/Java/HeroesOfZether/lib/lwjgl/native/linux/liblwjgl.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1880)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at org.lwjgl.Sys$1.run(Sys.java:72)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:96)
at org.lwjgl.Sys.<clinit>(Sys.java:117)
at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:39)
at java.security.AccessController.doPrivileged(Native Method)
at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:36)
at simpleslickgame.SimpleSlickGame.main(SimpleSlickGame.java:34)
我已經做了完全一樣the tutorial on Slick2D說,下載並解壓光滑和LWJGL檔案,創建了一個用戶庫,添加運行VM參數參考與原生文件夾(liblwjgl.so,liblwjgl32.so,libopenal.so,libopenal32.so)相關的文件夾,如您所見,JVM發現它們沒有問題,但隨後遇到體系結構衝突。我在32位Linux Mint上運行Eclipse,並使用JDK進行了正確的安裝和配置,我在沒有任何問題的情況下製作了一些小應用程序。在LWJGL站點上沒有單獨的32位下載選項,並且刪除名稱中不包含「32」的庫都返回UnsatisfiedLinkException:java.library.path中沒有lwjgl。這是測試應用代碼:
package simpleslickgame;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
public class SimpleSlickGame extends BasicGame
{
public SimpleSlickGame(String gamename)
{
super(gamename);
}
@Override
public void init(GameContainer gc) throws SlickException {}
@Override
public void update(GameContainer gc, int i) throws SlickException {}
@Override
public void render(GameContainer gc, Graphics g) throws SlickException
{
g.drawString("Howdy!", 10, 10);
}
public static void main(String[] args)
{
try
{
AppGameContainer appgc;
appgc = new AppGameContainer(new SimpleSlickGame("Simple Slick Game"));
appgc.setDisplayMode(640, 480, false);
appgc.start();
}
catch (SlickException ex)
{
Logger.getLogger(SimpleSlickGame.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
有人可以告訴我我做錯了什麼,以及如何解決它?
問題是,我不知道如何。在網站上沒有單獨的32位下載,就像我說過的,只留下名稱中包含「32」的庫只會導致不滿意的鏈接錯誤,並且留下並重命名它們也會產生錯誤。 – Deuxis
您是否嘗試過下載最新的LWJGL並按照[本指南](http://slick.ninjacave.com/wiki/index.php?title=Loading_libraries_and_natives_from_path)獲取SLICK以使用它們?你使用的是什麼按位版本的JDK? – Dawnkeeper
根據[this](https://bitbucket.org/kevglass/slick/commits/all)該項目已經死了(對不起),但你可能會發現一個仍在開發中的分支。 – Dawnkeeper