用于视频编码的 Java 类加载包含 C++ 代码的 DLL
Unpacking debugging symbols for VideoSource.dll to \path
Checking for VideoSource.pdb...
Checking for videosource.pdb...
然后尝试从该 DLL 实例化本机 (C++) 类:
// VideoSource() is implemented in C++ and wrapped with JNI,
// wrapper files were generated with SWIG
_videoProvider = new generated.VideoSource();
当 Java 类作为 JUnit 测试(提取视频数据)执行时,这种方法有效。
当我将 Java 类作为 OSGi 服务启动时,同样的事情也不起作用。
本质上,执行的是相同的代码。DLL 仍然成功加载,但上面显示的本机 (C++) 类的实例化现在引发异常:
java.lang.UnsatisfiedLinkError: generated.VideoSourceSWIGJNI.new_VideoSource()J
当我将 Java 类作为 OSGi 服务启动而不是作为 JUnit 测试执行时,有什么不同?我该怎么做才能让它发挥作用?
背景
生成.VideoSource() 是
public VideoSource() {
this(VideoSourceSWIGJNI.new_VideoSource(), true);
}
VideoSourceSWIGJNI.new_VideoSource() 是
public final static native long new_VideoSource();
C++ 实现是
VideoSource::VideoSource() {
// init frame count
m_frame_cnt = 0;
[..]
}