我正在尝试在使用sbt构建的Scala应用程序中使用opencv,这是我的build.sbt
name := "Marker"
version := "1.0"
scalaVersion := "2.11.8"
javaOptions in run += "-Djava.library.path=/home/priyatham/libs/opencv-3.1.0/build/lib"
这是我在sbt run
[error] (run-main-0) java.lang.UnsatisfiedLinkError: no opencv_java310 in java.library.path
java.lang.UnsatisfiedLinkError: no opencv_java310 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at Main$.main(Main.scala:10)
at Main.main(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
[trace] Stack trace suppressed: run last compile:run for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) Nonzero exit code: 1
[error] Total time: 1 s, completed 13 Sep, 2016 8:40:09 PM
我修改java.library.path
编辑:我确实将opencv-310.jar
放在Marker/lib
文件夹
使用java -Djava.library.path="/home/priyatham/libs/opencv-3.1.0/build/lib"
进行编译可以正常工作,但不适用于sbt run
答案 0 :(得分:2)
编辑:
添加fork in run := true
。我想现在它试图在同一个JVM中运行你的代码,所以不应用javaOptions。