нативная библиотека загрузки Java не может загрузить библиотеку — Linux fedora25 java8

Я пытаюсь загрузить динамическую библиотеку C ++, которую я скомпилировал в моей системе, чтобы сделать обертку в Java. Я мог сделать это в прошлом на окнах, но здесь я изо всех сил, чтобы загрузить библиотеку. Вот код:

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;

import java.io.File;

public interface libWrapper extends Library {

//  String path = "." + File.pathSeparator + "hiddenPath/lib/Dynamic";
//  System.setProperty("java.library.path", System.getProperty("java.library.path") + File.pathSeparator + path);
//      System.setProperty("java.library.path", path + File.pathSeparator
//          + System.getProperty("java.library.path"));

libWrapper INSTANCE = (libWrapper)
Native.loadLibrary(
"libgtengine.so",
libWrapper.class );

Pointer FrameCstructor(String name, long parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist);
}

Я попытался указать расположение библиотеки с разными методами, но безуспешно:

1) укажите -Djava.library.path = PATHTOLIBRARY

2) использовать System.setProperty, но это не увенчалось успехом, так как я не смог запустить код. Я получаю ошибку компиляции, которая говорит, что не удалось найти функцию setProperty (а также getProperty): Ошибка: (16, 35) Java: ожидается

3) скопируйте libgteengine.so в ту же папку, что и класс libWrapper.

Я подозреваю, что моя библиотека имеет неправильную сборку архитектуры?

вот сообщение об ошибке, которое я получаю при попытке загрузить его методом 1) и 3)

java.lang.UnsatisfiedLinkError: Unable to load library 'gtengine': Native library (linux-x86-64/libgtengine.so) not found in resource path ([file:/home/ycourvoisier/Documents/Softwares/ideaIU-2017.1/idea-IU-171.3780.107/lib/idea_rt.jar, file:/home/ycourvoisier/Documents/Softwares/ideaIU-2017.1/idea-IU-171.3780.107/plugins/junit/lib/junit-rt.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/charsets.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/deploy.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/cldrdata.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/dnsns.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/jaccess.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/jfxrt.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/localedata.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/nashorn.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/sunec.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/sunjce_provider.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/sunpkcs11.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/zipfs.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/javaws.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jce.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jfr.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jfxswt.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jsse.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/management-agent.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/plugin.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/resources.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/rt.jar, file:/home/ycourvoisier/Documents/Development/GitLocalRepo/com-enata-java-math/target/test-classes/, file:/home/ycourvoisier/Documents/Development/GitLocalRepo/com-enata-java-math/target/classes/, file:/home/ycourvoisier/.m2/repository/org/ejml/all/0.30/all-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/core/0.30/core-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/dense64/0.30/dense64-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/denseC64/0.30/denseC64-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/equation/0.30/equation-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/simple/0.30/simple-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-csv/1.4/commons-csv-1.4.jar, file:/home/ycourvoisier/.m2/repository/org/glassfish/javax.json/1.0.4/javax.json-1.0.4.jar, file:/home/ycourvoisier/.m2/repository/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar, file:/home/ycourvoisier/.m2/repository/org/hibernate/hibernate-jpamodelgen/5.1.4.Final/hibernate-jpamodelgen-5.1.4.Final.jar, file:/home/ycourvoisier/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/home/ycourvoisier/.m2/repository/javax/servlet/jsp/javax.servlet.jsp-api/2.2.1/javax.servlet.jsp-api-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/javax/el/el-api/2.2.1-b04/el-api-2.2.1-b04.jar, file:/home/ycourvoisier/.m2/repository/junit/junit/4.12/junit-4.12.jar, file:/home/ycourvoisier/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-dbcp2/2.1.1/commons-dbcp2-2.1.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-pool2/2.4.2/commons-pool2-2.4.2.jar, file:/home/ycourvoisier/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar, file:/home/ycourvoisier/.m2/repository/org/postgresql/postgresql/9.4.1212/postgresql-9.4.1212.jar, file:/home/ycourvoisier/.m2/repository/org/easymock/easymock/3.4/easymock-3.4.jar, file:/home/ycourvoisier/.m2/repository/org/objenesis/objenesis/2.2/objenesis-2.2.jar, file:/home/ycourvoisier/.m2/repository/org/slf4j/slf4j-simple/1.7.22/slf4j-simple-1.7.22.jar, file:/home/ycourvoisier/.m2/repository/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.jar, file:/home/ycourvoisier/.m2/repository/org/openjdk/jmh/jmh-core/1.17.4/jmh-core-1.17.4.jar, file:/home/ycourvoisier/.m2/repository/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-server/9.4.0.RC1/jetty-server-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-http/9.4.0.RC1/jetty-http-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-io/9.4.0.RC1/jetty-io-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-jndi/9.4.0.RC1/jetty-jndi-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-util/9.4.0.RC1/jetty-util-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-maven-plugin/9.4.0.RC1/jetty-maven-plugin-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-plugin-api/3.0.3/maven-plugin-api-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-model/3.0.3/maven-model-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/sisu/sisu-inject-plexus/2.1.1/sisu-inject-plexus-2.1.1.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.1.1/sisu-inject-bean-2.1.1.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/sisu/sisu-guice/2.9.4/sisu-guice-2.9.4-no_aop.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-artifact/3.0.3/maven-artifact-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-core/3.0.3/maven-core-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-settings/3.0.3/maven-settings-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-settings-builder/3.0.3/maven-settings-builder-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-repository-metadata/3.0.3/maven-repository-metadata-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-model-builder/3.0.3/maven-model-builder-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-aether-provider/3.0.3/maven-aether-provider-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-spi/1.11/aether-spi-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-impl/1.11/aether-impl-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-api/1.11/aether-api-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-util/1.11/aether-util-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-classworlds/2.4/plexus-classworlds-2.4.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.4/maven-plugin-tools-api-3.4.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-project/2.2.1/maven-project-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-profile/2.2.1/maven-profile-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-artifact-manager/2.2.1/maven-artifact-manager-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/wagon/wagon-provider-api/1.0-beta-6/wagon-provider-api-1.0-beta-6.jar, file:/home/ycourvoisier/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-9-stable-1/plexus-container-default-1.0-alpha-9-stable-1.jar, file:/home/ycourvoisier/.m2/repository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-plugin-descriptor/2.2.1/maven-plugin-descriptor-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-webapp/9.4.0.RC1/jetty-webapp-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-xml/9.4.0.RC1/jetty-xml-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-servlet/9.4.0.RC1/jetty-servlet-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-quickstart/9.4.0.RC1/jetty-quickstart-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-jaas/9.4.0.RC1/jetty-jaas-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-security/9.4.0.RC1/jetty-security-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-plus/9.4.0.RC1/jetty-plus-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-jmx/9.4.0.RC1/jetty-jmx-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-annotations/9.4.0.RC1/jetty-annotations-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar, file:/home/ycourvoisier/.m2/repository/org/ow2/asm/asm/5.1/asm-5.1.jar, file:/home/ycourvoisier/.m2/repository/org/ow2/asm/asm-commons/5.1/asm-commons-5.1.jar, file:/home/ycourvoisier/.m2/repository/org/ow2/asm/asm-tree/5.1/asm-tree-5.1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-server-impl/9.4.0.RC1/javax-websocket-server-impl-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-client-impl/9.4.0.RC1/javax-websocket-client-impl-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/javax/websocket/javax.websocket-api/1.0/javax.websocket-api-1.0.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-server/9.4.0.RC1/websocket-server-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-common/9.4.0.RC1/websocket-common-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-api/9.4.0.RC1/websocket-api-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-client/9.4.0.RC1/websocket-client-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-servlet/9.4.0.RC1/websocket-servlet-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/apache-jsp/9.4.0.RC1/apache-jsp-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/toolchain/jetty-schemas/3.1/jetty-schemas-3.1.jar, file:/home/ycourvoisier/.m2/repository/org/mortbay/jasper/apache-jsp/8.5.4/apache-jsp-8.5.4.jar, file:/home/ycourvoisier/.m2/repository/org/mortbay/jasper/apache-el/8.5.4/apache-el-8.5.4.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jdt/core/compiler/ecj/4.4.2/ecj-4.4.2.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/apache-jstl/9.4.0.RC1/apache-jstl-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/taglibs/taglibs-standard-spec/1.2.5/taglibs-standard-spec-1.2.5.jar, file:/home/ycourvoisier/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar, file:/home/ycourvoisier/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar, file:/home/ycourvoisier/Documents/Softwares/ideaIU-2017.1/idea-IU-171.3780.107/lib/idea_rt.jar])

Спасибо за ваше время и помощь

РЕДАКТИРОВАТЬ

public interface libWrapper extends Library {

static String path = "." + File.pathSeparator + "/home/ycourvoisier/Documents/Development/GitLocalRepo/hydros-mathLibrary/HydrosMathLibraryCode/lib/Dynamic";
static {
System.setProperty( "jna.library.path", path + File.pathSeparator
+ System.getProperty( "java.library.path" ) );
}libWrapper INSTANCE = (libWrapper)
Native.loadLibrary(
"libgtengine.so",
libWrapper.class );
}

это было предложено для использования setProperty системы. Но Java возвращает незаконное начало персонажа

EDIT2
Вот сокращенная версия, которая должна делать то же самое, но это тоже не работает. Путь указывается непосредственно в коде, поэтому не возникает путаницы в том, указан ли он:

public class Frame {

static {
System.setProperty( "jna.library.path", "/home/NAME/Documents/Development/GitLocalRepo/com-hidden-java-math/src" + File.pathSeparator + System.getProperty( "jna.library.path" ) );
}

public interface libWrapper extends Library {

libWrapper INSTANCE = (libWrapper)
Native.loadLibrary(
"gtengine",
libWrapper.class );

Pointer FrameCstructor(String name, long parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist);
}

private Pointer ptrToCFrame;

public Frame(String name, int parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist) {

ptrToCFrame = libWrapper.INSTANCE.FrameCstructor( name, parent,
x, y, z, rotX, rotY, rotZ,
vX, vY, vZ, angVx, angVy, angVz,
accX, accY, accZ, angAccX, angAccY, angAccZ,
addToFramelist );
}
}

0

Решение

Обязательно поместите файл в LD_LIBRARY_PATH.

Посмотрите здесь пример кода:

https://github.com/mkopsnc/keplerhacks/tree/master/jnijna

Если вы решили перейти на JNI, посмотрите здесь:

http://jnicookbook.owsiak.org

0

Другие решения

Решение проблемы загрузки библиотеки состояло в том, чтобы изменить код (здесь я все еще сомневаюсь в правильном способе сделать это)

public class Frame {

static {
System.loadLibrary( "gtengine" );
}

public static native Pointer FrameCstructor(String name, long parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist);

private Pointer ptrToCFrame;

public Frame(String name, int parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist) {

System.out.println("library: " + System.getProperty( "java.library.path" ));

ptrToCFrame = FrameCstructor( name, parent,
x, y, z, rotX, rotY, rotZ,
vX, vY, vZ, angVx, angVy, angVz,
accX, accY, accZ, angAccX, angAccY, angAccZ,
addToFramelist );
}
}

И мне пришлось указать путь к библиотеке libgtengine.so.3.7 (не укороченная версия libgtengine.so) в LD_LIBRARY_PATH переменная окружения. Это было обнаружено после прочтения ссылка на сайт (в видео) предоставлено участником @mko.

Это теперь создало другие трудности (UnsatisfiedLinkError неопределенный символ: XOpenDisplay), что я держу в другой момент.

Спасибо

0

По вопросам рекламы [email protected]