2014-08-29 140 views
3

我想使用無頭LibGDX進行單元測試,但是當我運行測試時出現此錯誤:如何解決「無法加載共享庫'libgdx64.so'爲目標:Linux,64位」

Couldn't load shared library 'libgdx64.so' for target: Linux, 64-bit

我讀here,我需要添加gdx-natives.jar。這是正確的,我在哪裏可以找到這個文件?

另外,在我的項目中,我應該添加文件?

+0

這裏下載:http://libgdx.badlogicgames.com/releases/ 這裏解釋:http://agmprojects.com/blog/setting-up-a-basic-libgdx-project – Guillaume 2014-08-29 15:08:16

+0

我想我應該提到我正在使用IntelliJ IDEA和LibGDX-setup-ui。我之前看過該教程,但由於它基於自定義Eclipse項目,所以似乎無法使其在我的項目中運行。 – twiz 2014-08-29 15:32:54

+0

可能會有所幫助:http://stackoverflow.com/questions/1051640/correct-way-to-add-lib-jar-to-an-intellij-idea-project – Guillaume 2014-08-29 16:31:00

回答

4

我在this BitBucket repo找到了答案。 README給出了一個很好的解釋,說明如何使用Gradle來實現這一點。

基本上,你只需要添加GdxTestRunner.java從回購,然後添加一個@RunWith到每個測試文件:

@RunWith(GdxTestRunner.class) 
public class MyClassTest { 
    ... 
} 

然後在你的根級別build.gradle文件,添加這樣的事情你core依賴關係:

testCompile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion" 
testCompile "com.badlogicgames.gdx:gdx:$gdxVersion" 
testCompile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" 
testCompile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" 
testCompile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop" 
testCompile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion" 
testCompile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop" 

顯然box2dbullet依賴,如果你正在使用這些庫纔有必要。


在到位桶回購README,示例包括

testCompile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion" 

compile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion" 

我不認爲這是必要的,包括本作compile,如果我正確瞭解Gradle是如何工作的,它實際上會減慢你的構建速度。