6

I'm trying to link my JNI Android application with OpenCV but I get these errors

./obj/local/armeabi
/libopencv_calib3d.a(calibinit.cpp.o): In function `cvDrawChessboardCorners':
calibinit.cpp:(.text+0x20a): undefined reference to `cvLine'
calibinit.cpp:(.text+0x244): undefined reference to `cvLine'
calibinit.cpp:(.text+0x26e): undefined reference to `cvCircle'
calibinit.cpp:(.text+0x2ec): undefined reference to `cvLine'
calibinit.cpp:(.text+0x4ce): undefined reference to `cvLine'
calibinit.cpp:(.text+0x504): undefined reference to `cvLine'
calibinit.cpp:(.text+0x532): undefined reference to `cvCircle'
./obj/local/armeabi/libopencv_calib3d.a(calibinit.cpp.o): In function `cvFindChessboardCorners':
calibinit.cpp:(.text+0x1b6a): undefined reference to `cvRectangle'
./obj/local/armeabi/libopencv_calib3d.a(calibinit.cpp.o): In function `cv::findCirclesGrid(cv::_InputArray const&, cv::Size_<int>, cv::_OutputArray const&, int, cv::Ptr<cv::FeatureDetector> const&)':
calibinit.cpp:(.text+0x5058): undefined reference to `cv::FeatureDetector::detect(cv::Mat const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, cv::Mat const&) const'
./obj/local/armeabi/libopencv_calib3d.a(circlesgrid.cpp.o): In function `cv::findCirclesGridDefault(cv::_InputArray const&, cv::Size_<int>, cv::_OutputArray const&, int)':
circlesgrid.cpp:(.text+0x2ce): undefined reference to `cv::SimpleBlobDetector::Params::Params()'
circlesgrid.cpp:(.text+0x2dc): undefined reference to `cv::SimpleBlobDetector::SimpleBlobDetector(cv::SimpleBlobDetector::Params const&)'
./obj/local/armeabi/libopencv_calib3d.a(circlesgrid.cpp.o): In function `CirclesGridFinder::drawHoles(cv::Mat const&, cv::Mat&) const':
circlesgrid.cpp:(.text+0xa56): undefined reference to `cv::line(cv::Mat&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
circlesgrid.cpp:(.text+0xafa): undefined reference to `cv::line(cv::Mat&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
circlesgrid.cpp:(.text+0xb44): undefined reference to `cv::circle(cv::Mat&, cv::Point_<int>, int, cv::Scalar_<double> const&, int, int, int)'
./obj/local/armeabi/libopencv_calib3d.a(circlesgrid.cpp.o): In function `CirclesGridFinder::drawBasis(std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > const&, cv::Point_<float>, cv::Mat&) const':
circlesgrid.cpp:(.text+0x106c): undefined reference to `cv::line(cv::Mat&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
./obj/local/armeabi/libopencv_calib3d.a(circlesgrid.cpp.o): In function `CirclesGridFinder::drawBasisGraphs(std::vector<Graph, std::allocator<Graph> > const&, cv::Mat&, bool, bool) const':
circlesgrid.cpp:(.text+0x133c): undefined reference to `cv::circle(cv::Mat&, cv::Point_<int>, int, cv::Scalar_<double> const&, int, int, int)'
circlesgrid.cpp:(.text+0x13bc): undefined reference to `cv::line(cv::Mat&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
./obj/local/armeabi/libopencv_calib3d.a(circlesgrid.cpp.o): In function `CirclesGridClusterFinder::parsePatternPoints(std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > const&, std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > const&, std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >&)':
circlesgrid.cpp:(.text+0x3292): undefined reference to `cv::flann::LinearIndexParams::LinearIndexParams()'
circlesgrid.cpp:(.text+0x32c6): undefined reference to `cv::flann::Index::Index(cv::_InputArray const&, cv::flann::IndexParams const&, cvflann::flann_distance_t)'
circlesgrid.cpp:(.text+0x346a): undefined reference to `cv::flann::SearchParams::SearchParams(int, float, bool)'
circlesgrid.cpp:(.text+0x347e): undefined reference to `cv::flann::Index::knnSearch(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, cv::flann::SearchParams const&)'
circlesgrid.cpp:(.text+0x3484): undefined reference to `cv::flann::IndexParams::~IndexParams()'
circlesgrid.cpp:(.text+0x3658): undefined reference to `cv::flann::Index::~Index()'
circlesgrid.cpp:(.text+0x365e): undefined reference to `cv::flann::IndexParams::~IndexParams()'
circlesgrid.cpp:(.text+0x36b6): undefined reference to `cv::flann::Index::~Index()'
circlesgrid.cpp:(.text+0x36bc): undefined reference to `cv::flann::IndexParams::~IndexParams()'
circlesgrid.cpp:(.text+0x3702): undefined reference to `cv::flann::IndexParams::~IndexParams()'
circlesgrid.cpp:(.text+0x370c): undefined reference to `cv::flann::Index::~Index()'
./obj/local/armeabi/libopencv_calib3d.a(circlesgrid.cpp.o): In function `CirclesGridFinder::computeRNG(Graph&, std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >&, cv::Mat*) const':
circlesgrid.cpp:(.text+0x4b2a): undefined reference to `cv::line(cv::Mat&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
circlesgrid.cpp:(.text+0x4b7e): undefined reference to `cv::circle(cv::Mat&, cv::Point_<int>, int, cv::Scalar_<double> const&, int, int, int)'
circlesgrid.cpp:(.text+0x4bd4): undefined reference to `cv::circle(cv::Mat&, cv::Point_<int>, int, cv::Scalar_<double> const&, int, int, int)'
./obj/local/armeabi/libopencv_imgproc.a(contours.cpp.o): In function `cv::drawContours(cv::_OutputArray const&, cv::_InputArray const&, int, cv::Scalar_<double> const&, int, int, cv::_InputArray const&, int, cv::Point_<int>)':
contours.cpp:(.text+0x3fd2): undefined reference to `cvDrawContours'
./obj/local/armeabi/libopencv_imgproc.a(samplers.cpp.o): In function `cvSampleLine':
samplers.cpp:(.text+0x65a2): undefined reference to `cvInitLineIterator'
./obj/local/armeabi/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::crossCorr(cv::Mat const&, cv::Mat const&, cv::Mat&, cv::Size_<int>, int, cv::Point_<int>, double, int)':
templmatch.cpp:(.text+0x47e): undefined reference to `cv::getOptimalDFTSize(int)'
templmatch.cpp:(.text+0x494): undefined reference to `cv::getOptimalDFTSize(int)'
templmatch.cpp:(.text+0x92c): undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
templmatch.cpp:(.text+0xfa4): undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
templmatch.cpp:(.text+0x1006): undefined reference to `cv::mulSpectrums(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, bool)'
templmatch.cpp:(.text+0x102e): undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libarengine.so] Error 1

I'm linking with 3 modules: opencv_core opencv_calib3d opencv_imgproc. What am I missing ?

Edit. I've added opencv_flann library and reduced the error count. But where are cv::line or for example cv::rectangle are defined ?

0

3 Answers 3

20

The problem was in the libraries order. The correct order is:

LOCAL_STATIC_LIBRARIES :=  libopencv_calib3d opencv_features2d opencv_flann opencv_imgproc opencv_core

So the main principle is you have to declare libraries in reverse order of their dependency (e.g. *opencv_imgproc* depends on *opencv_core* and *opencv_features2d* depends on *opencv_imgproc* and so on).

Sign up to request clarification or add additional context in comments.

Comments

2

You are missing opencv_highgui and probably opencv_features2d as well.

cv::rectangle is defined at opencv_core.

Make sure that your file is being linked with all these libraries.

Comments

2

You can also look at the output of pkg-config --static --libs opencv to arrange the libraries in the correct order.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.