QT5.5+Opencv3.0.0 Undefined symbols for architecture x86_64S

asked 2015-07-12 08:05:00 -0500

diego Max gravatar image

updated 2015-07-17 15:09:10 -0500

I tried to use SURF detector and descriptor in opencv3.0.0. However, the error is

Undefined symbols for architecture x86_64:
"cv::xfeatures2d::SURF::create(double, int, int, bool, bool)", referenced from:
  _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

QT project setting

QT       += core

QT       -= gui

TARGET = test4
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

INCLUDEPATH += /usr/local/include
INCLUDEPATH += /usr/local/include/opencv
INCLUDEPATH += /usr/local/include/opencv2

LIBS += -L/usr/local/lib \
 -lopencv_calib3d \
 -lopencv_core \
 -lopencv_features2d \
 -lopencv_flann \
 -lopencv_highgui \
 -lopencv_imgcodecs \
 -lopencv_imgproc \
 -lopencv_ml \
 -lopencv_objdetect \
 -lopencv_photo \


SOURCES += main.cpp

Code

#include <iostream>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/opencv.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <opencv2/xfeatures2d/nonfree.hpp>

using namespace cv;
using namespace std;
using namespace cv::xfeatures2d;

int main(int argc, char *argv[])
{

    Mat img_1 = imread( "../testImg/left.jpg", CV_LOAD_IMAGE_GRAYSCALE );
    Mat img_2 = imread( "../testImg/right.jpg", CV_LOAD_IMAGE_GRAYSCALE );
    imshow("Display1",img_1);
    imshow("Display2",img_2);
    if( !img_1.data || !img_2.data ){ std::cout<< 'no image loaded' <<std::endl; }
    std::cout<< 'it works!' <<std::endl;
    //-- Step 1: Detect the keypoints using SURF Detector
    double minHessian = 1000;

    Ptr<Feature2D> f2d = SURF::create(minHessian);
    //    Ptr<Feature2D> f2d = ORB::create();
}

I have checked that nonfree and xfeatures2d are already installed by using cmake.

Ptr<Feature2D> f2d = ORB::create(); // is worked but SURF and SIFT don't.

Compiler Error:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -mmacosx-version-min=10.10 -Wl,-rpath,/Users/tianshi/Qt/5.5/clang_64/lib -o test_cv.app/Contents/MacOS/test_cv main.o mainwindow.o moc_mainwindow.o   -F/Users/tianshi/Qt/5.5/clang_64/lib -L/usr/local/lib -lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -framework QtOpenGL -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL 

Undefined symbols for architecture x86_64:
"cv::xfeatures2d::SIFT::create(int, int, double, double, double)", referenced from:
  MainWindow::MainWindow(QWidget*) in mainwindow.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test_cv.app/Contents/MacOS/test_cv] Error 1

Error while building/deploying project test_cv (kit: Desktop Qt 5.5.0 clang 64bit)
When executing step "Make"
22:04:37: Elapsed time: 00:00.
edit retag flag offensive close merge delete

Comments

1

you need the opencv_contrib repo for SIFT and SURF. this will also give you the missing xfeatures2d module

and then: Ptr<feature2d> f2d = xfeatures2d::SURF::create();

and -lopencv_xfeatures2d

berak gravatar imageberak ( 2015-07-12 08:17:47 -0500 )edit

hello berak, thanks for your suggestion. I have already installed the opencv_contrib repo by cmake. The strange thing is I haven't libopencv_xfeatures2d.dylib. There is only libopencv_xfeatures2d.a in my /usr/local/lib folder.

diego Max gravatar imagediego Max ( 2015-07-12 08:38:02 -0500 )edit

Hi diego Max , How did you resolve this issue. I too have a similar issue, Can you please provide inputs...

rajesh_5445 gravatar imagerajesh_5445 ( 2018-04-19 23:59:47 -0500 )edit