我试图通过Ubuntu上的Java Native Interface运行本机OpenCV函数。最终我要尝试完成的是使用默认版本的OpenCV中可用的bagofwords
函数,但目前我正在尝试使用此接口测试运行简单函数。 / p>
所以,我有以下带有相对原生函数的Java文件。
class OpenCVSample {
static {
System.loadLibrary("Bridge1");
}
public native int BridgeFunction();
public static void main(String[] args) {
OpenCVSample b = new OpenCVSample();
b.BridgeFunction();
}
}
这是我的C ++ Bridge
文件。
#include "OpenCVSample.h"
#include <string.h>
#include <cv.h>
JNIEXPORT jint JNICALL Java_OpenCVSample_BridgeFunction(JNIEnv *env, jobject obj) {
IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
return 1;
}
int main(){}
正如我所提到的,我在Ubuntu上这样做,所以我首先使用带有gcc
的jdk将OpenCV编译到共享库中,并使用以下命令。
g++ -shared -o libBridge1.so Bridge1.cpp -fPIC -I/usr/lib/jvm/java-1.7.0-openjdk-amd64/include -I/usr/lib/jvm/java-1.7.0-openjdk-amd64/include/linux -I/var/opencv/opencv/include/opencv
-I/var/opencv/opencv/modules/core/include
-I/var/opencv/opencv/modules/imgproc/include
-I/var/opencv/opencv/modules/features2d/include
-I/var/opencv/opencv/modules/flann/include
-I/var/opencv/opencv/modules/calib3d/include
-I/var/opencv/opencv/modules/objdetect/include
-I/var/opencv/opencv/modules/legacy/include
-I/var/opencv/opencv/modules/highgui/include
然后创建一个名为libBridge1.so
的共享库。现在当我尝试运行Java文件本身时出现问题,我得到以下错误。
java:符号查找错误:/var/tests/oc/libBridge1.so:undefined symbol:cvCreateImage
我已经对此进行了相当多的研究,我几乎可以肯定我正确地创建了共享库,因此无法理解为什么我会收到此错误,谁能解释一下?
----------------------------------- 的修改 的 -----------------------------------
感谢用户Andrew Henle和James Black的建议。我已经开始使用以下命令链接各个库。
g++ -shared -o libBridge1.so OpenCVSample.cpp -fPIC -I/usr/lib/jvm/java-1.7.0-openjdk-amd64/include -I/usr/lib/jvm/java-1.7.0-openjdk-amd64/include/linux -I/var/opencv/opencv/include -I/var/opencv/opencv/include/opencv -I/var/opencv/opencv/modules/core/include -I/var/opencv/opencv/modules/imgproc/include -I/var/opencv/opencv/modules/photo/include -I/var/opencv/opencv/modules/objdetect/include -L/var/opencv/opencv/build/lib -lopencv_core -L/var/opencv/opencv/build/lib -lopencv_imgproc -L/var/opencv/opencv/build/lib -lopencv_highgui -L/var/opencv/opencv/build/lib -lopencv_objdetect -L/var/opencv/opencv/build/lib -lopencv_features2d -L/var/opencv/opencv/build/lib -lopencv_video -L/var/opencv/opencv/build/lib -lopencv_core249
图书馆似乎在编译,但现在问题似乎是它充满undefined references
。在ld
上运行libBridge1.so
命令时,我得到以下错误流。
ld: warning: cannot find entry symbol _start; not setting start address
libBridge1.so: undefined reference to `ippicviMirror_32s_C4R'
libBridge1.so: undefined reference to `ippicviTranspose_8u_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_16u_C4R'
libBridge1.so: undefined reference to `ippicviSub_8u_C1RSfs'
libBridge1.so: undefined reference to `ippicviTranspose_32s_C1IR'
libBridge1.so: undefined reference to `ippicviSum_32f_C3R'
libBridge1.so: undefined reference to `pthread_mutex_trylock'
libBridge1.so: undefined reference to `ippicviMean_16u_C1MR'
libBridge1.so: undefined reference to `ippicviTranspose_16s_C3R'
libBridge1.so: undefined reference to `ippicviNorm_L2_16s_C3R'
libBridge1.so: undefined reference to `ippicviXor_8u_C1R'
libBridge1.so: undefined reference to `ippicviMirror_8u_C4R'
libBridge1.so: undefined reference to `ippicviNorm_Inf_16u_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_16u_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_16u_C3CMR'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_32f_C3R'
libBridge1.so: undefined reference to `ippicviNorm_L2_32f_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_16s_C3R'
libBridge1.so: undefined reference to `ippicviNorm_L1_8s_C1MR'
libBridge1.so: undefined reference to `ippicviSet_16u_C3MR'
libBridge1.so: undefined reference to `gzeof'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_32f_C1MR'
libBridge1.so: undefined reference to `ippicviTranspose_16u_C3IR'
libBridge1.so: undefined reference to `ippicviSum_16u_C4R'
libBridge1.so: undefined reference to `ippicviAbsDiff_8u_C1R'
libBridge1.so: undefined reference to `ippicviNormRel_L2_8u_C1MR'
libBridge1.so: undefined reference to `ippicviAbsDiff_16u_C1R'
libBridge1.so: undefined reference to `ippicvsMinEvery_16u'
libBridge1.so: undefined reference to `ippicvMalloc'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_32f_C1MR'
libBridge1.so: undefined reference to `ippicviMirror_16u_C3IR'
libBridge1.so: undefined reference to `ippicviConvert_8s32f_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_16s_C4R'
libBridge1.so: undefined reference to `ippicvsFlip_32f_I'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_16u_C3R'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_8u_C3CMR'
libBridge1.so: undefined reference to `ippicviTranspose_16u_C1IR'
libBridge1.so: undefined reference to `ippicviSub_16u_C1RSfs'
libBridge1.so: undefined reference to `ippicviSet_16u_C4MR'
libBridge1.so: undefined reference to `ippicviTranspose_8u_C3IR'
libBridge1.so: undefined reference to `ippicviNorm_L1_16u_C3R'
libBridge1.so: undefined reference to `gzopen'
libBridge1.so: undefined reference to `ippicviTranspose_16u_C1R'
libBridge1.so: undefined reference to `ippicviMean_32f_C3CMR'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_32f_C1MR'
libBridge1.so: undefined reference to `pthread_mutexattr_settype'
libBridge1.so: undefined reference to `gzclose'
libBridge1.so: undefined reference to `ippicviNorm_L2_16u_C4R'
libBridge1.so: undefined reference to `ippicviCompare_16s_C1R'
libBridge1.so: undefined reference to `ippicviMax_8u_C1R'
libBridge1.so: undefined reference to `ippicviMean_16s_C3R'
libBridge1.so: undefined reference to `ippicviConvert_32f16u_C1RSfs'
libBridge1.so: undefined reference to `ippicviConvert_32s32f_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_8u_C1MR'
libBridge1.so: undefined reference to `ippicviMean_8u_C1R'
libBridge1.so: undefined reference to `ippicviMirror_16s_C3R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_32f_C4R'
libBridge1.so: undefined reference to `ippicviNormRel_L1_8u_C1MR'
libBridge1.so: undefined reference to `pthread_key_create'
libBridge1.so: undefined reference to `ippicviMirror_16u_C1IR'
libBridge1.so: undefined reference to `ippicviNormRel_L2_16u_C1R'
libBridge1.so: undefined reference to `gzrewind'
libBridge1.so: undefined reference to `ippicviMirror_32s_C1R'
libBridge1.so: undefined reference to `ippicviAdd_32f_C1R'
libBridge1.so: undefined reference to `ippicviNorm_L1_8u_C1MR'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_32f_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_8u_C4R'
libBridge1.so: undefined reference to `ippicviSum_8u_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_8s_C1MR'
libBridge1.so: undefined reference to `ippicviConvert_16u32s_C1R'
libBridge1.so: undefined reference to `ippicviNorm_L1_16s_C4R'
libBridge1.so: undefined reference to `ippicviConvert_16u8s_C1RSfs'
libBridge1.so: undefined reference to `ippicviMirror_16s_C4IR'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_16u_C3CMR'
libBridge1.so: undefined reference to `ippicviNormRel_L1_16u_C1MR'
libBridge1.so: undefined reference to `ippicviCompare_8u_C1R'
libBridge1.so: undefined reference to `ippicviMinMaxIndx_32f_C1MR'
libBridge1.so: undefined reference to `ippicviMirror_32f_C4IR'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_32f_C4R'
libBridge1.so: undefined reference to `ippicviSum_16s_C3R'
libBridge1.so: undefined reference to `ippicviMin_32f_C1R'
libBridge1.so: undefined reference to `ippicviNorm_L1_16s_C3R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_16s_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_32f_C1R'
libBridge1.so: undefined reference to `dlsym'
libBridge1.so: undefined reference to `ippicviNormRel_L2_16s_C1R'
libBridge1.so: undefined reference to `ippicviCopy_32s_C3MR'
libBridge1.so: undefined reference to `ippicviConvert_16u8u_C1R'
libBridge1.so: undefined reference to `ippicviSet_16s_C4MR'
libBridge1.so: undefined reference to `ippicviMax_16s_C1R'
libBridge1.so: undefined reference to `ippicviMinMaxIndx_8u_C1MR'
libBridge1.so: undefined reference to `pthread_once'
libBridge1.so: undefined reference to `ippicviNormRel_L2_8s_C1MR'
libBridge1.so: undefined reference to `ippicviNorm_L1_32f_C1MR'
libBridge1.so: undefined reference to `ippicviTranspose_8u_C4IR'
libBridge1.so: undefined reference to `ippicviConvert_16s32s_C1R'
libBridge1.so: undefined reference to `ippicviCopy_8u_C1R'
libBridge1.so: undefined reference to `ippicvsMinEvery_8u'
libBridge1.so: undefined reference to `ippicvsFlip_64f_I'
libBridge1.so: undefined reference to `ippicvsMaxEvery_32f'
libBridge1.so: undefined reference to `ippicviMirror_32f_C1R'
libBridge1.so: undefined reference to `ippicviNormRel_L1_16u_C1R'
libBridge1.so: undefined reference to `ippicviNormRel_L2_32f_C1MR'
libBridge1.so: undefined reference to `ippicviNorm_L1_16u_C4R'
libBridge1.so: undefined reference to `ippicviAdd_16u_C1RSfs'
libBridge1.so: undefined reference to `ippicviNorm_L2_16s_C4R'
libBridge1.so: undefined reference to `ippicviMean_8u_C1MR'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_16u_C3R'
libBridge1.so: undefined reference to `ippicviMul_16u_C1RSfs'
libBridge1.so: undefined reference to `ippicvsMaxEvery_64f'
libBridge1.so: undefined reference to `ippicviMirror_16u_C3R'
libBridge1.so: undefined reference to `ippicviTranspose_32s_C4IR'
libBridge1.so: undefined reference to `ippicviMirror_8u_C3IR'
libBridge1.so: undefined reference to `ippicviConvert_32s8u_C1R'
libBridge1.so: undefined reference to `ippicviTranspose_16s_C3IR'
libBridge1.so: undefined reference to `ippicviSum_8u_C3R'
libBridge1.so: undefined reference to `ippicviNorm_Inf_32f_C4R'
libBridge1.so: undefined reference to `ippicviTranspose_8u_C3R'
libBridge1.so: undefined reference to `ippicviMinMaxIndx_8s_C1MR'
libBridge1.so: undefined reference to `ippicviConvert_32s16u_C1RSfs'
libBridge1.so: undefined reference to `ippicviConvert_8s8u_C1Rs'
libBridge1.so: undefined reference to `ippicviNormRel_Inf_32f_C1MR'
libBridge1.so: undefined reference to `ippicviTranspose_8u_C1IR'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_8s_C3CMR'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_8u_C4R'
libBridge1.so: undefined reference to `ippicvsSortAscend_8u_I'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_16u_C1MR'
libBridge1.so: undefined reference to `ippicviConvert_32f32s_C1RSfs'
libBridge1.so: undefined reference to `ippicviTranspose_16s_C1R'
libBridge1.so: undefined reference to `ippicviCopy_32s_C4MR'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_8u_C3CMR'
libBridge1.so: undefined reference to `ippicviNorm_L2_16u_C3R'
libBridge1.so: undefined reference to `pthread_getspecific'
libBridge1.so: undefined reference to `ippicviSet_32s_C4MR'
libBridge1.so: undefined reference to `ippicviNorm_Inf_16u_C3R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_32f_C3R'
libBridge1.so: undefined reference to `ippicviTranspose_32s_C1R'
libBridge1.so: undefined reference to `ippicvInit'
libBridge1.so: undefined reference to `ippicviMean_8u_C3CMR'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_8u_C3R'
libBridge1.so: undefined reference to `ippicviNorm_L1_32f_C3R'
libBridge1.so: undefined reference to `pthread_mutexattr_destroy'
libBridge1.so: undefined reference to `ippicviNorm_Inf_8u_C4R'
libBridge1.so: undefined reference to `ippicviConvert_32s16s_C1RSfs'
libBridge1.so: undefined reference to `ippicviMul_16s_C1RSfs'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_8s_C1MR'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_16u_C4R'
libBridge1.so: undefined reference to `ippicviMean_StdDev_8u_C3CMR'
libBridge1.so: undefined reference to `ippicviMirror_32s_C4IR'
libBridge1.so: undefined reference to `ippicviCopy_16u_C1MR'
libBridge1.so: undefined reference to `ippicviMean_StdDev_16u_C1MR'
libBridge1.so: undefined reference to `ippicviNormRel_L1_32f_C1MR'
libBridge1.so: undefined reference to `ippicviConvert_32f8s_C1RSfs'
libBridge1.so: undefined reference to `ippicviSum_16u_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_8u_C1R'
libBridge1.so: undefined reference to `ippicviMirror_8u_C3R'
libBridge1.so: undefined reference to `ippicviNorm_L1_16u_C1R'
libBridge1.so: undefined reference to `ippicviMirror_32s_C1IR'
libBridge1.so: undefined reference to `ippicviMul_32f_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_16s_C4R'
libBridge1.so: undefined reference to `ippicviTranspose_32s_C4R'
libBridge1.so: undefined reference to `ippicviConvert_32s8s_C1R'
libBridge1.so: undefined reference to `ippicviTranspose_16u_C4R'
libBridge1.so: undefined reference to `ippicviNorm_L2_16u_C1MR'
libBridge1.so: undefined reference to `ippicviNorm_Inf_16s_C4R'
libBridge1.so: undefined reference to `ippicviTranspose_32f_C4IR'
libBridge1.so: undefined reference to `ippicviNorm_L2_8u_C3R'
libBridge1.so: undefined reference to `ippicviMean_16u_C4R'
libBridge1.so: undefined reference to `ippicviTranspose_16s_C4R'
libBridge1.so: undefined reference to `ippicviMean_32f_C1R'
libBridge1.so: undefined reference to `ippicviNot_8u_C1R'
libBridge1.so: undefined reference to `ippicviNorm_Inf_8u_C3R'
libBridge1.so: undefined reference to `ippicviNorm_L2_16s_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_16u_C1MR'
libBridge1.so: undefined reference to `ippicviLUTPalette_8u_C4R'
libBridge1.so: undefined reference to `ippicviMirror_16u_C4R'
libBridge1.so: undefined reference to `ippicviTranspose_32f_C1IR'
libBridge1.so: undefined reference to `ippicviNormRel_Inf_16s_C1R'
libBridge1.so: undefined reference to `ippicviMean_StdDev_16u_C3CMR'
libBridge1.so: undefined reference to `ippicviSub_16s_C1RSfs'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_8u_C1R'
libBridge1.so: undefined reference to `ippicviNorm_Inf_32f_C3R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_16u_C1MR'
libBridge1.so: undefined reference to `ippicviCopy_8u_C3MR'
libBridge1.so: undefined reference to `ippicviNorm_L1_32f_C1R'
libBridge1.so: undefined reference to `ippicviMirror_32s_C3R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_16u_C3R'
libBridge1.so: undefined reference to `ippicviMean_8u_C3R'
libBridge1.so: undefined reference to `pthread_mutexattr_init'
libBridge1.so: undefined reference to `ippicviNorm_Inf_16s_C1R'
libBridge1.so: undefined reference to `ippicviConvert_16s8s_C1RSfs'
libBridge1.so: undefined reference to `ippicviNormRel_Inf_32f_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_8s_C3CMR'
libBridge1.so: undefined reference to `ippicviNormRel_L2_16u_C1MR'
libBridge1.so: undefined reference to `ippicviMinMaxIndx_8s_C1R'
libBridge1.so: undefined reference to `ippicviNorm_L1_16s_C1R'
libBridge1.so: undefined reference to `ippicviMean_StdDev_8u_C3CR'
libBridge1.so: undefined reference to `ippicviSet_32f_C3MR'
libBridge1.so: undefined reference to `ippicviConvert_8s16s_C1R'
libBridge1.so: undefined reference to `ippicviAdd_8u_C1RSfs'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_32f_C3R'
libBridge1.so: undefined reference to `ippicviConvert_16u16s_C1RSfs'
libBridge1.so: undefined reference to `ippicviSet_16s_C3MR'
libBridge1.so: undefined reference to `ippicviTranspose_32f_C1R'
libBridge1.so: undefined reference to `ippicviSum_16u_C3R'
libBridge1.so: undefined reference to `ippicviMirror_16s_C3IR'
libBridge1.so: undefined reference to `ippicviNorm_Inf_8s_C1MR'
libBridge1.so: undefined reference to `ippicviConvert_8s16u_C1Rs'
libBridge1.so: undefined reference to `ippicviNorm_L2_32f_C3R'
libBridge1.so: undefined reference to `ippicviMean_16u_C1R'
libBridge1.so: undefined reference to `ippicviNorm_L1_8u_C3R'
libBridge1.so: undefined reference to `ippicviCopy_8u_C3P3R'
libBridge1.so: undefined reference to `ippicviCopy_16u_C3MR'
libBridge1.so: undefined reference to `ippicviNorm_L2_16u_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_8u_C3R'
libBridge1.so: undefined reference to `ippicviSum_8u_C4R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_16u_C1R'
libBridge1.so: undefined reference to `ippicviMean_32f_C1MR'
libBridge1.so: undefined reference to `ippicviTranspose_16s_C4IR'
libBridge1.so: undefined reference to `ippicviMirror_8u_C1IR'
libBridge1.so: undefined reference to `ippicviTranspose_32f_C4R'
libBridge1.so: undefined reference to `ippicviMean_StdDev_32f_C1MR'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_16s_C4R'
libBridge1.so: undefined reference to `ippicviNormRel_Inf_16u_C1R'
libBridge1.so: undefined reference to `ippicviSum_16s_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_16s_C3R'
libBridge1.so: undefined reference to `ippicviMean_16u_C3R'
libBridge1.so: undefined reference to `ippicviDotProd_16u64f_C1R'
libBridge1.so: undefined reference to `ippicviCompare_16u_C1R'
libBridge1.so: undefined reference to `ippicviMean_StdDev_16u_C3CR'
libBridge1.so: undefined reference to `ippicviNorm_L2_8u_C4R'
libBridge1.so: undefined reference to `ippicviMirror_8u_C4IR'
libBridge1.so: undefined reference to `ippicvsDotProd_64f'
libBridge1.so: undefined reference to `ippicviSet_32f_C4MR'
libBridge1.so: undefined reference to `ippicvsMinEvery_32f'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_32f_C3CMR'
libBridge1.so: undefined reference to `ippicviNorm_L2_8u_C1MR'
libBridge1.so: undefined reference to `ippicviNorm_Inf_16s_C3R'
libBridge1.so: undefined reference to `ippicviSum_32f_C4R'
libBridge1.so: undefined reference to `ippicviNormRel_L1_32f_C1R'
libBridge1.so: undefined reference to `ippicviTranspose_16u_C4IR'
libBridge1.so: undefined reference to `ippicviNorm_Inf_8u_C1MR'
libBridge1.so: undefined reference to `ippicviSub_32f_C1R'
libBridge1.so: undefined reference to `ippicviMax_16u_C1R'
libBridge1.so: undefined reference to `ippicviMean_StdDev_8u_C1MR'
libBridge1.so: undefined reference to `ippicviTranspose_32f_C3R'
libBridge1.so: undefined reference to `ippicviSum_32f_C1R'
libBridge1.so: undefined reference to `ippicviMinMaxIndx_8u_C1R'
libBridge1.so: undefined reference to `ippicviMin_16u_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_8s_C1MR'
libBridge1.so: undefined reference to `ippicviSet_32s_C3MR'
libBridge1.so: undefined reference to `ippicviNorm_L2_8s_C1MR'
libBridge1.so: undefined reference to `ippicviMax_32f_C1R'
libBridge1.so: undefined reference to `ippicviNorm_L2_32f_C1MR'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_16u_C4R'
libBridge1.so: undefined reference to `ippicviNorm_L1_16u_C1MR'
libBridge1.so: undefined reference to `ippicviNorm_L1_32f_C4R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_32f_C3CMR'
libBridge1.so: undefined reference to `ippicviCopy_8u_C4P4R'
libBridge1.so: undefined reference to `ippicvsMaxEvery_16u'
libBridge1.so: undefined reference to `ippicviNormRel_Inf_8s_C1MR'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_8u_C1R'
libBridge1.so: undefined reference to `ippicviTranspose_16s_C1IR'
libBridge1.so: undefined reference to `ippicviCopy_8u_C1MR'
libBridge1.so: undefined reference to `ippicviSet_32s_C1MR'
libBridge1.so: undefined reference to `ippicvsFlip_8u_I'
libBridge1.so: undefined reference to `ippicviConvert_8u32s_C1R'
libBridge1.so: undefined reference to `ippicviNormRel_Inf_8u_C1MR'
libBridge1.so: undefined reference to `ippicviTranspose_32s_C3R'
libBridge1.so: undefined reference to `ippicvsMinEvery_64f'
libBridge1.so: undefined reference to `ippicviTranspose_16u_C3R'
libBridge1.so: undefined reference to `ippicviConvert_8u16s_C1R'
libBridge1.so: undefined reference to `ippicviCopy_32s_C1MR'
libBridge1.so: undefined reference to `ippicviConvert_8u8s_C1RSfs'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_16s_C1R'
libBridge1.so: undefined reference to `ippicviDotProd_16s64f_C1R'
libBridge1.so: undefined reference to `ippicviSet_16s_C1MR'
libBridge1.so: undefined reference to `ippicviNorm_L1_8u_C1R'
libBridge1.so: undefined reference to `ippicviNorm_L2_32f_C4R'
libBridge1.so: undefined reference to `ippicviOr_8u_C1R'
libBridge1.so: undefined reference to `ippicviMirror_8u_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_8u_C3R'
libBridge1.so: undefined reference to `ippicviTranspose_32s_C3IR'
libBridge1.so: undefined reference to `ippicviMirror_16s_C1R'
libBridge1.so: undefined reference to `ippicviMean_16s_C4R'
libBridge1.so: undefined reference to `ippicviMean_16s_C1R'
libBridge1.so: undefined reference to `ippicviConvert_32f8u_C1RSfs'
libBridge1.so: undefined reference to `ippicviConvert_16s32f_C1R'
libBridge1.so: undefined reference to `ippicviMin_8u_C1R'
libBridge1.so: undefined reference to `ippicviNorm_L2_8u_C1R'
libBridge1.so: undefined reference to `ippicviLUTPalette_8u_C3R'
libBridge1.so: undefined reference to `gzgets'
libBridge1.so: undefined reference to `ippicviMirror_32f_C1IR'
libBridge1.so: undefined reference to `ippicviAdd_16s_C1RSfs'
libBridge1.so: undefined reference to `ippicviMean_StdDev_32f_C3CR'
libBridge1.so: undefined reference to `ippicviConvert_8u16u_C1R'
libBridge1.so: undefined reference to `ippicviMean_StdDev_32f_C3CMR'
libBridge1.so: undefined reference to `ippicviMirror_32f_C4R'
libBridge1.so: undefined reference to `ippicviNorm_Inf_8u_C1R'
libBridge1.so: undefined reference to `ippicviMul_8u_C1RSfs'
libBridge1.so: undefined reference to `ippicviTranspose_32f_C3IR'
libBridge1.so: undefined reference to `ippicviMin_16s_C1R'
libBridge1.so: undefined reference to `ippicviNormRel_L2_8u_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_32f_C4R'
libBridge1.so: undefined reference to `ippicviMirror_32s_C3IR'
libBridge1.so: undefined reference to `ippicviMirror_16s_C1IR'
libBridge1.so: undefined reference to `ippicviMean_8u_C4R'
libBridge1.so: undefined reference to `ippicviNormRel_Inf_8u_C1R'
libBridge1.so: undefined reference to `ippicviNorm_L1_8u_C4R'
libBridge1.so: undefined reference to `ippicviNormRel_Inf_16u_C1MR'
libBridge1.so: undefined reference to `ippicviNormRel_L1_8s_C1MR'
libBridge1.so: undefined reference to `ippicviMean_32f_C3R'
libBridge1.so: undefined reference to `ippicviMean_32f_C4R'
libBridge1.so: undefined reference to `ippicviMirror_32f_C3R'
libBridge1.so: undefined reference to `gzputs'
libBridge1.so: undefined reference to `ippicviMirror_32f_C3IR'
libBridge1.so: undefined reference to `ippicviAbsDiff_32f_C1R'
libBridge1.so: undefined reference to `ippicvsFlip_16u_I'
libBridge1.so: undefined reference to `ippicviNormRel_L1_16s_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_32f_C1R'
libBridge1.so: undefined reference to `ippicviConvert_16s16u_C1Rs'
libBridge1.so: undefined reference to `ippicvsDotProd_32f64f'
libBridge1.so: undefined reference to `ippicviMean_StdDev_8u_C1R'
libBridge1.so: undefined reference to `ippicviMirror_16u_C1R'
libBridge1.so: undefined reference to `ippicviMinMaxIndx_16u_C1MR'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_32f_C3CMR'
libBridge1.so: undefined reference to `ippicviConvert_16u32f_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_8u_C1MR'
libBridge1.so: undefined reference to `ippicvFree'
libBridge1.so: undefined reference to `ippicviNorm_Inf_32f_C1R'
libBridge1.so: undefined reference to `ippicviSet_32f_C1MR'
libBridge1.so: undefined reference to `ippicviMinMaxIndx_16u_C1R'
libBridge1.so: undefined reference to `ippicvsMaxEvery_8u'
libBridge1.so: undefined reference to `ippicviTranspose_8u_C4R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_16s_C3R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_8s_C3CMR'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_8u_C1MR'
libBridge1.so: undefined reference to `ippicviMinMaxIndx_32f_C1R'
libBridge1.so: undefined reference to `dlopen'
libBridge1.so: undefined reference to `ippicviMirror_16s_C4R'
libBridge1.so: undefined reference to `ippicviNormDiff_L2_8u_C4R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_8u_C3CMR'
libBridge1.so: undefined reference to `ippicviSum_16s_C4R'
libBridge1.so: undefined reference to `pthread_setspecific'
libBridge1.so: undefined reference to `ippicviMean_StdDev_16u_C1R'
libBridge1.so: undefined reference to `ippicviNormRel_L1_8u_C1R'
libBridge1.so: undefined reference to `ippicviMean_16u_C3CMR'
libBridge1.so: undefined reference to `ippicviCompare_32f_C1R'
libBridge1.so: undefined reference to `ippicviNorm_Inf_16u_C4R'
libBridge1.so: undefined reference to `ippicviNormRel_L2_32f_C1R'
libBridge1.so: undefined reference to `ippicviNorm_Inf_32f_C1MR'
libBridge1.so: undefined reference to `ippicviConvert_16s8u_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_Inf_16u_C1R'
libBridge1.so: undefined reference to `ippicviAnd_8u_C1R'
libBridge1.so: undefined reference to `ippicviConvert_8s32s_C1R'
libBridge1.so: undefined reference to `ippicviNormDiff_L1_16u_C3CMR'
libBridge1.so: undefined reference to `ippicviMean_StdDev_32f_C1R'
libBridge1.so: undefined reference to `ippicviConvert_8u32f_C1R'
libBridge1.so: undefined reference to `ippicviSet_16u_C1MR'
libBridge1.so: undefined reference to `ippicviDotProd_32s64f_C1R'
libBridge1.so: undefined reference to `ippicviMirror_16u_C4IR'
libBridge1.so: undefined reference to `ippicvsSortDescend_8u_I'
当运行java文件本身时,我现在遇到了这个问题:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /var/tests/oc/libBridge1.so: /var/tests/oc/libBridge1.so: undefined symbol: ippicviMinMaxIndx_16u_C1R
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1855)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at Bridge1.<clinit>(OpenCVSample.java:4)
--------------------------------- 编辑2 的 ---------------------------------
经过一些进一步的修补后,我发现了获取未定义引用的问题。我正在链接到错误的核心文件。然而,问题仍然存在,只是规模较小。以下是我使用的命令:
g++ -Wall -shared-libgcc -Im -o libBridge1.so Bridge1.cpp -fPIC -I/usr/lib/jvm/java-1.7.0-openjdk-amd64/include -I/usr/lib/jvm/java-1.7.0-openjdk-amd64/include/linux -I/var/opencv/opencv/include -I/var/opencv/opencv/include/opencv -I/var/opencv/opencv/modules/core/include -I/var/opencv/opencv/modules/imgproc/include -I/var/opencv/opencv/modules/photo/include -I/var/opencv/opencv/modules/objdetect/include -I/var/opencv/opencv/modules/imgcodecs/include -I/var/opencv/opencv/modules/videoio/include -I/var/opencv/opencv/modules/highgui/include -L/var/opencv/opencv/build/lib -lopencv_core249 -L/var/opencv/opencv/build/lib -lopencv_features2d -L/var/opencv/opencv/build/lib -lopencv_imgproc -I/var/opencv/opencv/build/lib
在编译过程中,我现在收到此错误:
Bridge1.cpp: In function ‘jint Java_Bridge1_BridgeFunction(JNIEnv*, jobject)’:
Bridge1.cpp:8:12: warning: unused variable ‘img’ [-Wunused-variable]
IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
^
/tmp/ccqbVddx.o: In function `Java_Bridge1_BridgeFunction':
Bridge1.cpp:(.text+0x63): undefined reference to `cvCreateImage'
collect2: error: ld returned 1 exit status
答案 0 :(得分:2)
您需要将您的共享对象与所需的&#34; -l ...&#34;选项,就像编译正常的C / C ++可执行文件来运行相同的函数一样。
如果你做了一个&#34; ldd libBridge1.so&#34;你应该看到所需的库。如果您没有看到所需的库,则需要将它们添加到链接步骤。
答案 1 :(得分:2)
我同意Andrew Henie关于-l
旗帜,因为我很好奇你的图书馆是如何编制的。
但是在你的java类中,首先要调用System.loadLibrary(..)
加载你的库。
然后我预计它会失败,使用ld
命令将有助于指出你缺少的东西。