dyld:惰性符号绑定失败:未找到符号:预期在:flat namespace中

时间:2017-05-19 18:10:18

标签: c++ opencv intellij-idea java-native-interface jniwrapper

我最近将OpenCv更新到版本3.2.0,并且不得不重写我的一些JNI包装器。但是,现在它给我这个错误:

dyld: lazy symbol binding failed: Symbol not found: 
ZN2cv4MSER6createEiiiddiddi
  Referenced from: /Users/kve/Documents/Projects/NU/bot/JDA/libs/libmser.dylib
  Expected in: flat namespace

dyld: Symbol not found: __ZN2cv4MSER6createEiiiddiddi
  Referenced from: /Users/kve/Documents/Projects/NU/bot/JDA/libs/libmser.dylib
  Expected in: flat namespace

这是我使用MSER::create函数的结果。我已经尝试返回新Mat的地址并且没有出现任何错误,因此我认为这与其他人与MacOS和dylib相关的类似错误无关(即其他人在加载库时出现问题)一般情况下,而我的只有MSER::create)。相信我,我一直在网上搜索至少2个小时的解决方案,我找不到一个。

以下是我的MSER.cpp文件中的相关代码:

JNIEXPORT jlong JNICALL Java_org_opencv_features2d_MSER_create_11(JNIEnv* env, jclass cls, jint delta, jint min_area, jint max_area, jdouble max_variation, jdouble min_diversity, jint max_evolution, jdouble area_threshold, jdouble min_margin, jint edge_blur_size)
{
    static const char method_name[] = "MSSR::create_1";

    Ptr<Feature2D> pointer = MSER::create(delta, min_area, max_area, max_variation, min_diversity, max_evolution, area_threshold, min_margin, edge_blur_size);
    MSER* mser = pointer.dynamicCast<MSER>();
    jlong addr = reinterpret_cast<jlong>(mser);

    return addr;
}

JNI包装器的代码:

package org.opencv.features2d;

import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.MatOfRect;

import java.io.File;

public class MSER extends FeatureDetector{
    static {
        System.load(new File("libs/libmser.dylib").getAbsolutePath());
    }

    public MSER(long addr) {
        super(addr);
    }

    //          MSER( int _delta=5, int _min_area=60, int _max_area=14400, double _max_variation=0.25, double _min_diversity=.2,
    // C++:     int _max_evolution=200, double _area_threshold=1.01,
    //          double _min_margin=0.003, int _edge_blur_size=5 )

    public MSER(int delta, int minArea, int maxArea, double maxVariation, double minDiversity, int maxEvolution, double areaThreshold, double minMargin, int edgeBlurSize) {
        super(create_1(delta, minArea, maxArea, maxVariation, minDiversity, maxEvolution, areaThreshold, minMargin, edgeBlurSize));
    }


    public MSER() {
        this(5, 60, 14400, 0.25, .2, 200, 1.01, 0.003, 5);
    }

    public void detectRegions(Mat image, MatOfKeyPoint msers, MatOfRect bboxes) {
        detectRegions_0(nativeObj, image.nativeObj, msers.nativeObj, bboxes.nativeObj);
    }

    private static native long create_1(int delta, int minArea, int maxArea, double maxVariation, double minDiversity, int maxEvolution, double areaThreshold, double minMargin, int edgeBlurSize);

    private native void detectRegions_0(long nativeObj, long image_nativeObj, long msers_nativeObj, long bboxes_nativeObj);
}

任何帮助将不胜感激!

谢谢,
基拉

0 个答案:

没有答案