简体   繁体   English

如何加载原生库来播放框架

[英]How to load native library to play framework

I have been trying to develop a play framework application.我一直在尝试开发一个播放框架应用程序。 i am using opencv (.jar + native library) in this application.我在这个应用程序中使用 opencv(.jar + 本机库)。 When i try to run the application with当我尝试运行应用程序时

play start

command the application runs fine and perfect.命令应用程序运行良好且完美。 when tried with尝试时

play run

and it needs to access the opencv methods it gets a runtime error saying它需要访问 opencv 方法,它得到一个运行时错误说

java.lang.UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_0(Ljava/lang/String;I)J
    at org.opencv.highgui.Highgui.imread_0(Native Method)
    at org.opencv.highgui.Highgui.imread(Highgui.java:299)
    at com.allspark.scanners.LabelImScanner.readLabel(LabelImScanner.java:39)
    at com.allspark.controllers.imageController.uploadLabel(imageController.java:55)
    at Routes$$anonfun$routes$1$$anonfun$applyOrElse$19$$anonfun$apply$19.apply(routes_routing.scala:289)
    at Routes$$anonfun$routes$1$$anonfun$applyOrElse$19$$anonfun$apply$19.apply(routes_routing.scala:289)

then I tried to run the application in production mode then everything works fine.然后我尝试在生产模式下运行应用程序然后一切正常。 I need to know how to load the native library to play application runs in development mode.我需要知道如何加载本机库以在开发模式下运行应用程序。 This issue already discussed in followings: https://groups.google.com/forum/#!topic/play-framework/A3cL3dkD70I https://github.com/playframework/playframework/issues/2212 How to include native library (JNI) in play 2.1 RC2?这个问题已经在下面讨论过: https : //groups.google.com/forum/#! topic /play-framework/A3cL3dkD70I https://github.com/playframework/playframework/issues/2212 如何包含本机库(JNI ) 在玩 2.1 RC2?

but unfortunately nothing works for development mode application.但不幸的是,对于开发模式应用程序没有任何作用。 I am using play famework 2.2.0 and opencv-246.我正在使用 play famework 2.2.0 和 opencv-246。 If anyone can give support that would be great help.Thank you.如果有人可以提供支持,那将是非常有帮助的。谢谢。 Appreciate your help感谢你的帮助

There are two ways:有两种方式:

1. Create a /lib folder in you play project and then play clean and compile (SBT will take care of every thing) 1.在你的play项目中创建一个/lib文件夹,然后play clean和compile(SBT会处理所有事情)

2. 2.

cp  opencv-2412.jar /your-play-project/target/native_libraries/64bits/
cp  ibopencv_java2412.dylib  /your-play-project/target/native_libraries/64bits/

then play clean and compile然后播放干净并编译

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM