Ask Your Question

Revision history [back]

OpenCV 3.2.0 cannnot access to SURF/SIFT in xfeatures2d

I am using Qt creator in Ubuntu 16.04 to build a non-Qt project. I need to use SIFT to detect features. I know that SIFT and SURF are in OpenCV_contrib so I add the extra module when using CMake-gui to configure OpenCV.

Then I can find libopencv_xfeatures2d.so/.so.3.2/.so.3.2.0 and also libopencv_features2d.so/.so.3.2/.so.3.2.0 in /usr/local/lib When I am using the code from OpenCV official website: test code to test SIFT, I still get the error

/home/ronjane92/Documents/Qt/OpenCV/build/lib/libslam_essentials.so:-1: error: undefined reference to `cv::xfeatures2d::SIFT::create(int, int, double, double, double)'

:-1: error: collect2: error: ld returned 1 exit status

My CMakeLists.txt has the following things:

    CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
    PROJECT(opencv_test)

    include( CheckCXXCompilerFlag )
    SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")

    FIND_PACKAGE( PCL 1.7 REQUIRED COMPONENTS common io visualization)
    ADD_DEFINITIONS( ${PCL_DEFINITIONS} )
    INCLUDE_DIRECTORIES( ${PCL_INCLUDE_DIRS} )
    LINK_DIRECTORIES( ${PCL_LIBRARY_DIRS} )

    ADD_SUBDIRECTORY(lib)
    INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib )
    LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/lib )

    FIND_PACKAGE( OpenCV 3.1.0 REQUIRED )
    INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} )

    ADD_EXECUTABLE(${PROJECT_NAME} "main.cpp")
    TARGET_LINK_LIBRARIES(opencv_test ${OpenCV_LIBRARIES}
                                      ${PCL_LIBRARIES}
                                      realsense
                                      slam_essentials
                         )

The results from Cmake-gui are
Detected version of GNU GCC: 54 (504)
FP16: Feature disabled
Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") 
Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") 
Found OpenEXR: /usr/lib/x86_64-linux-gnu/libIlmImf.so
Checking for module 'gstreamer-base-1.0'
  No package 'gstreamer-base-1.0' found
Checking for module 'gstreamer-video-1.0'
  No package 'gstreamer-video-1.0' found
Checking for module 'gstreamer-app-1.0'
  No package 'gstreamer-app-1.0' found
Checking for module 'gstreamer-riff-1.0'
  No package 'gstreamer-riff-1.0' found
Checking for module 'gstreamer-pbutils-1.0'
  No package 'gstreamer-pbutils-1.0' found
Checking for module 'gstreamer-base-0.10'
  No package 'gstreamer-base-0.10' found
Checking for module 'gstreamer-video-0.10'
  No package 'gstreamer-video-0.10' found
Checking for module 'gstreamer-app-0.10'
  No package 'gstreamer-app-0.10' found
Checking for module 'gstreamer-riff-0.10'
  No package 'gstreamer-riff-0.10' found
Checking for module 'gstreamer-pbutils-0.10'
  No package 'gstreamer-pbutils-0.10' found
Looking for linux/videodev.h
Looking for linux/videodev.h - not found
Looking for linux/videodev2.h
Looking for linux/videodev2.h - found
Looking for sys/videoio.h
Looking for sys/videoio.h - not found
WARNING, PrimeSensor Module binaries directory (set by OPENNI_PRIME_SENSOR_MODULE_BIN_DIR variable) is not found or does not have PrimeSensor Module binaries.
Checking for module 'libavresample'
  No package 'libavresample' found
Checking for module 'libgphoto2'
  No package 'libgphoto2' found
Found TBB: /usr/lib/x86_64-linux-gnu/libtbb.so
found IPP (ICV version): 9.0.1 [9.0.1]
at: /home/ronjane92/Programs/opencv/opencv-3.2.0-build/3rdparty/ippicv/ippicv_lnx
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find Atlas (missing:  Atlas_CLAPACK_INCLUDE_DIR) 
Could NOT find JNI (missing:  JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

Found VTK ver. 6.2.0 (usefile: /usr/lib/cmake/vtk-6.2/UseVTK.cmake)
Caffe:   NO
Protobuf:   YES
Glog:   NO
freetype2:   YES
harfbuzz:    YES
Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
freetype2:   YES
harfbuzz:    YES
Checking for modules 'tesseract;lept'
  No package 'tesseract' found
  No package 'lept' found
Tesseract:   NO
Check contents of vgg_generated_48.i ...
Check contents of vgg_generated_64.i ...
Check contents of vgg_generated_80.i ...
Check contents of vgg_generated_120.i ...
Check contents of boostdesc_bgm.i ...
Check contents of boostdesc_bgm_bi.i ...
Check contents of boostdesc_bgm_hd.i ...
Check contents of boostdesc_binboost_064.i ...
Check contents of boostdesc_binboost_128.i ...
Check contents of boostdesc_binboost_256.i ...
Check contents of boostdesc_lbgm.i ...

General configuration for OpenCV 3.2.0 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            /home/ronjane92/Programs/opencv/opencv_contrib-3.2.0/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2017-09-16T18:20:02Z
    Host:                        Linux 4.8.0-58-generic x86_64
    CMake:                       3.5.1
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 5.4.0)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):
    Linker flags (Debug):
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:          Qt5::Test Qt5::Concurrent Qt5::OpenGL /usr/lib/x86_64-linux-gnu/libwebp.so /usr/lib/x86_64-linux-gnu/libjasper.so /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so dc1394 avcodec-ffmpeg avformat-ffmpeg avutil-ffmpeg swscale-ffmpeg /usr/lib/libOpenNI.so Qt5::Core Qt5::Gui Qt5::Widgets /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so /usr/lib/x86_64-linux-gnu/libpthread.so /usr/lib/x86_64-linux-gnu/libsz.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libm.so vtkRenderingOpenGL vtkImagingHybrid vtkIOImage vtkCommonDataModel vtkCommonMath vtkCommonCore vtksys vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkCommonExecutionModel vtkDICOMParser vtkIOCore /usr/lib/x86_64-linux-gnu/libz.so vtkmetaio /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libtiff.so vtkImagingCore vtkRenderingCore vtkCommonColor vtkFiltersExtraction vtkFiltersCore vtkFiltersGeneral vtkCommonComputationalGeometry vtkFiltersStatistics vtkImagingFourier vtkalglib vtkFiltersGeometry vtkFiltersSources vtkInteractionStyle vtkRenderingLOD vtkFiltersModeling vtkIOPLY vtkIOGeometry /usr/lib/x86_64-linux-gnu/libjsoncpp.so vtkFiltersTexture vtkRenderingFreeType /usr/lib/x86_64-linux-gnu/libfreetype.so vtkftgl vtkIOExport vtkRenderingAnnotation vtkImagingColor vtkRenderingContext2D vtkRenderingGL2PS vtkRenderingContextOpenGL /usr/lib/libgl2ps.so vtkRenderingLabel dl m pthread rt /usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so tbb
    3rdparty dependencies:       libprotobuf

  OpenCV modules:
    To be built:                 core flann hdf imgproc ml photo reg surface_matching video viz dnn freetype fuzzy imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib cvv datasets rgbd stereo tracking videostab xfeatures2d ximgproc aruco optflow phase_unwrapping stitching structured_light python2
    Disabled:                    world contrib_world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python3 cnn_3dobj matlab sfm

  Non-free algorithms are enabled

  GUI: 
    QT 5.x:                      YES (ver 5.5.1)
    QT OpenGL support:           YES (Qt5::OpenGL 5.5.1)
    OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so)
    VTK support:                 YES (ver 6.2.0)

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x0202)
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.6)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2.2.0)
    GDAL:                        NO
    GDCM:                        NO

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.4)
    FFMPEG:                      YES
      avcodec:                   YES (ver 56.60.100)
      avformat:                  YES (ver 56.40.101)
      avutil:                    YES (ver 54.31.100)
      swscale:                   YES (ver 3.1.101)
      avresample:                NO
    GStreamer:                   NO
    OpenNI:                      YES (ver 1.5.4, build 0)
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    Aravis SDK:                  NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    NO/YES
    XIMEA:                       NO
    Xine:                        NO
    gPhoto2:                     NO

  Parallel framework:            TBB (ver 4.4 interface 9002)

  Other third-party libraries:
    Use IPP:                     9.0.1 [9.0.1]
         at:                     /home/ronjane92/Programs/opencv/opencv-3.2.0-build/3rdparty/ippicv/ippicv_lnx
    Use IPP Async:               NO
    Use VA:                      NO
    Use Intel VA-API/OpenCL:     NO
    Use Lapack:                  NO
    Use Eigen:                   YES (ver 3.2.92)
    Use Cuda:                    NO
    Use OpenCL:                  YES
    Use OpenVX:                  NO
    Use custom HAL:              NO

  OpenCL:                        <Dynamic loading of OpenCL library>
    Include path:                /home/ronjane92/Programs/opencv/opencv-3.2.0-source/3rdparty/include/opencl/1.2
    Use AMDFFT:                  NO
    Use AMDBLAS:                 NO

  Python 2:
    Interpreter:                 /usr/bin/python2.7 (ver 2.7.12)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
    numpy:                       /home/ronjane92/.local/lib/python2.7/site-packages/numpy/core/include (ver 1.13.1)
    packages path:               lib/python2.7/dist-packages

  Python 3:
    Interpreter:                 /usr/bin/python3 (ver 3.5.2)

  Python (for build):            /usr/bin/python2.7

  Java:
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        Matlab not found or implicitly disabled

  Documentation:
    Doxygen:                     /usr/bin/doxygen (ver 1.8.11)

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  /usr/local

  cvconfig.h is in:              /home/ronjane92/Programs/opencv/opencv-3.2.0-build
-----------------------------------------------------------------

Configuring done
Generating done

This is a repeated question so I've tried to google for solutions but none of them worked in my situation. Anyone who can help me out? Thanks.

OpenCV 3.2.0 cannnot access to SURF/SIFT in xfeatures2d

I am using Qt creator in Ubuntu 16.04 to build a non-Qt project. I need to use SIFT to detect features. I know that SIFT and SURF are in OpenCV_contrib so I add the extra module when using CMake-gui to configure OpenCV.

Then I can find libopencv_xfeatures2d.so/.so.3.2/.so.3.2.0 and also libopencv_features2d.so/.so.3.2/.so.3.2.0 in /usr/local/lib When I am using the code from OpenCV official website: test code to test SIFT, I still get the error

/home/ronjane92/Documents/Qt/OpenCV/build/lib/libslam_essentials.so:-1: error: undefined reference to `cv::xfeatures2d::SIFT::create(int, int, double, double, double)'

:-1: error: collect2: error: ld returned 1 exit status

My CMakeLists.txt has the following things:

    CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
    PROJECT(opencv_test)

    include( CheckCXXCompilerFlag )
    SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")

    FIND_PACKAGE( PCL 1.7 REQUIRED COMPONENTS common io visualization)
    ADD_DEFINITIONS( ${PCL_DEFINITIONS} )
    INCLUDE_DIRECTORIES( ${PCL_INCLUDE_DIRS} )
    LINK_DIRECTORIES( ${PCL_LIBRARY_DIRS} )

    ADD_SUBDIRECTORY(lib)
    INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib )
    LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/lib )

    FIND_PACKAGE( OpenCV 3.1.0 REQUIRED )
    INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} )

    ADD_EXECUTABLE(${PROJECT_NAME} "main.cpp")
    TARGET_LINK_LIBRARIES(opencv_test ${OpenCV_LIBRARIES}
                                      ${PCL_LIBRARIES}
                                      realsense
                                      slam_essentials
                         )

The results from Cmake-gui are
Detected version of GNU GCC: 54 (504)
FP16: Feature disabled
Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") 
Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") 
Found OpenEXR: /usr/lib/x86_64-linux-gnu/libIlmImf.so
Checking for module 'gstreamer-base-1.0'
  No package 'gstreamer-base-1.0' found
Checking for module 'gstreamer-video-1.0'
  No package 'gstreamer-video-1.0' found
Checking for module 'gstreamer-app-1.0'
  No package 'gstreamer-app-1.0' found
Checking for module 'gstreamer-riff-1.0'
  No package 'gstreamer-riff-1.0' found
Checking for module 'gstreamer-pbutils-1.0'
  No package 'gstreamer-pbutils-1.0' found
Checking for module 'gstreamer-base-0.10'
  No package 'gstreamer-base-0.10' found
Checking for module 'gstreamer-video-0.10'
  No package 'gstreamer-video-0.10' found
Checking for module 'gstreamer-app-0.10'
  No package 'gstreamer-app-0.10' found
Checking for module 'gstreamer-riff-0.10'
  No package 'gstreamer-riff-0.10' found
Checking for module 'gstreamer-pbutils-0.10'
  No package 'gstreamer-pbutils-0.10' found
Looking for linux/videodev.h
Looking for linux/videodev.h - not found
Looking for linux/videodev2.h
Looking for linux/videodev2.h - found
Looking for sys/videoio.h
Looking for sys/videoio.h - not found
WARNING, PrimeSensor Module binaries directory (set by OPENNI_PRIME_SENSOR_MODULE_BIN_DIR variable) is not found or does not have PrimeSensor Module binaries.
Checking for module 'libavresample'
  No package 'libavresample' found
Checking for module 'libgphoto2'
  No package 'libgphoto2' found
Found TBB: /usr/lib/x86_64-linux-gnu/libtbb.so
found IPP (ICV version): 9.0.1 [9.0.1]
at: /home/ronjane92/Programs/opencv/opencv-3.2.0-build/3rdparty/ippicv/ippicv_lnx
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find Atlas (missing:  Atlas_CLAPACK_INCLUDE_DIR) 
Could NOT find JNI (missing:  JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

Found VTK ver. 6.2.0 (usefile: /usr/lib/cmake/vtk-6.2/UseVTK.cmake)
Caffe:   NO
Protobuf:   YES
Glog:   NO
freetype2:   YES
harfbuzz:    YES
Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
freetype2:   YES
harfbuzz:    YES
Checking for modules 'tesseract;lept'
  No package 'tesseract' found
  No package 'lept' found
Tesseract:   NO
Check contents of vgg_generated_48.i ...
Check contents of vgg_generated_64.i ...
Check contents of vgg_generated_80.i ...
Check contents of vgg_generated_120.i ...
Check contents of boostdesc_bgm.i ...
Check contents of boostdesc_bgm_bi.i ...
Check contents of boostdesc_bgm_hd.i ...
Check contents of boostdesc_binboost_064.i ...
Check contents of boostdesc_binboost_128.i ...
Check contents of boostdesc_binboost_256.i ...
Check contents of boostdesc_lbgm.i ...

General configuration for OpenCV 3.2.0 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            /home/ronjane92/Programs/opencv/opencv_contrib-3.2.0/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2017-09-16T18:20:02Z
    Host:                        Linux 4.8.0-58-generic x86_64
    CMake:                       3.5.1
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 5.4.0)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):
    Linker flags (Debug):
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:          Qt5::Test Qt5::Concurrent Qt5::OpenGL /usr/lib/x86_64-linux-gnu/libwebp.so /usr/lib/x86_64-linux-gnu/libjasper.so /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so dc1394 avcodec-ffmpeg avformat-ffmpeg avutil-ffmpeg swscale-ffmpeg /usr/lib/libOpenNI.so Qt5::Core Qt5::Gui Qt5::Widgets /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so /usr/lib/x86_64-linux-gnu/libpthread.so /usr/lib/x86_64-linux-gnu/libsz.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libm.so vtkRenderingOpenGL vtkImagingHybrid vtkIOImage vtkCommonDataModel vtkCommonMath vtkCommonCore vtksys vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkCommonExecutionModel vtkDICOMParser vtkIOCore /usr/lib/x86_64-linux-gnu/libz.so vtkmetaio /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libtiff.so vtkImagingCore vtkRenderingCore vtkCommonColor vtkFiltersExtraction vtkFiltersCore vtkFiltersGeneral vtkCommonComputationalGeometry vtkFiltersStatistics vtkImagingFourier vtkalglib vtkFiltersGeometry vtkFiltersSources vtkInteractionStyle vtkRenderingLOD vtkFiltersModeling vtkIOPLY vtkIOGeometry /usr/lib/x86_64-linux-gnu/libjsoncpp.so vtkFiltersTexture vtkRenderingFreeType /usr/lib/x86_64-linux-gnu/libfreetype.so vtkftgl vtkIOExport vtkRenderingAnnotation vtkImagingColor vtkRenderingContext2D vtkRenderingGL2PS vtkRenderingContextOpenGL /usr/lib/libgl2ps.so vtkRenderingLabel dl m pthread rt /usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so tbb
    3rdparty dependencies:       libprotobuf

  OpenCV modules:
    To be built:                 core flann hdf imgproc ml photo reg surface_matching video viz dnn freetype fuzzy imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib cvv datasets rgbd stereo tracking videostab xfeatures2d ximgproc aruco optflow phase_unwrapping stitching structured_light python2
    Disabled:                    world contrib_world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python3 cnn_3dobj matlab sfm

  Non-free algorithms are enabled

  GUI: 
    QT 5.x:                      YES (ver 5.5.1)
    QT OpenGL support:           YES (Qt5::OpenGL 5.5.1)
    OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so)
    VTK support:                 YES (ver 6.2.0)

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x0202)
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.6)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2.2.0)
    GDAL:                        NO
    GDCM:                        NO

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.4)
    FFMPEG:                      YES
      avcodec:                   YES (ver 56.60.100)
      avformat:                  YES (ver 56.40.101)
      avutil:                    YES (ver 54.31.100)
      swscale:                   YES (ver 3.1.101)
      avresample:                NO
    GStreamer:                   NO
    OpenNI:                      YES (ver 1.5.4, build 0)
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    Aravis SDK:                  NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    NO/YES
    XIMEA:                       NO
    Xine:                        NO
    gPhoto2:                     NO

  Parallel framework:            TBB (ver 4.4 interface 9002)

  Other third-party libraries:
    Use IPP:                     9.0.1 [9.0.1]
         at:                     /home/ronjane92/Programs/opencv/opencv-3.2.0-build/3rdparty/ippicv/ippicv_lnx
    Use IPP Async:               NO
    Use VA:                      NO
    Use Intel VA-API/OpenCL:     NO
    Use Lapack:                  NO
    Use Eigen:                   YES (ver 3.2.92)
    Use Cuda:                    NO
    Use OpenCL:                  YES
    Use OpenVX:                  NO
    Use custom HAL:              NO

  OpenCL:                        <Dynamic loading of OpenCL library>
    Include path:                /home/ronjane92/Programs/opencv/opencv-3.2.0-source/3rdparty/include/opencl/1.2
    Use AMDFFT:                  NO
    Use AMDBLAS:                 NO

  Python 2:
    Interpreter:                 /usr/bin/python2.7 (ver 2.7.12)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
    numpy:                       /home/ronjane92/.local/lib/python2.7/site-packages/numpy/core/include (ver 1.13.1)
    packages path:               lib/python2.7/dist-packages

  Python 3:
    Interpreter:                 /usr/bin/python3 (ver 3.5.2)

  Python (for build):            /usr/bin/python2.7

  Java:
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        Matlab not found or implicitly disabled

  Documentation:
    Doxygen:                     /usr/bin/doxygen (ver 1.8.11)

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  /usr/local

  cvconfig.h is in:              /home/ronjane92/Programs/opencv/opencv-3.2.0-build
-----------------------------------------------------------------

Configuring done
Generating done

This is a repeated question so I've tried to google for solutions but none of them worked in my situation. Anyone who can help me out? Those two lines of output when I tried to run the code are the only errors I got. No error appears when I make & make install OpenCV libs. Thanks.

OpenCV 3.2.0 cannnot access to SURF/SIFT in xfeatures2d

I am using Qt creator in Ubuntu 16.04 to build a non-Qt project. I need to use SIFT to detect features. I know that SIFT and SURF are in OpenCV_contrib so I add the extra module when using CMake-gui to configure OpenCV.

Then I can find libopencv_xfeatures2d.so/.so.3.2/.so.3.2.0 and also libopencv_features2d.so/.so.3.2/.so.3.2.0 in /usr/local/lib When I am using the code from OpenCV official website: test code to test SIFT, I still get the error

/home/ronjane92/Documents/Qt/OpenCV/build/lib/libslam_essentials.so:-1: error: undefined reference to `cv::xfeatures2d::SIFT::create(int, int, double, double, double)'

:-1: error: collect2: error: ld returned 1 exit status

My CMakeLists.txt has the following things:

    CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
    PROJECT(opencv_test)

    include( CheckCXXCompilerFlag )
    SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")

    FIND_PACKAGE( PCL 1.7 REQUIRED COMPONENTS common io visualization)
    ADD_DEFINITIONS( ${PCL_DEFINITIONS} )
    INCLUDE_DIRECTORIES( ${PCL_INCLUDE_DIRS} )
    LINK_DIRECTORIES( ${PCL_LIBRARY_DIRS} )

    ADD_SUBDIRECTORY(lib)
    INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib )
    LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/lib )

    FIND_PACKAGE( OpenCV 3.1.0 REQUIRED )
    INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} )

    ADD_EXECUTABLE(${PROJECT_NAME} "main.cpp")
    TARGET_LINK_LIBRARIES(opencv_test ${OpenCV_LIBRARIES}
                                      ${PCL_LIBRARIES}
                                      realsense
                                      slam_essentials
                         )

The results from Cmake-gui are
Detected version of GNU GCC: 54 (504)
FP16: Feature disabled
Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") 
Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") 
Found OpenEXR: /usr/lib/x86_64-linux-gnu/libIlmImf.so
Checking for module 'gstreamer-base-1.0'
  No package 'gstreamer-base-1.0' found
Checking for module 'gstreamer-video-1.0'
  No package 'gstreamer-video-1.0' found
Checking for module 'gstreamer-app-1.0'
  No package 'gstreamer-app-1.0' found
Checking for module 'gstreamer-riff-1.0'
  No package 'gstreamer-riff-1.0' found
Checking for module 'gstreamer-pbutils-1.0'
  No package 'gstreamer-pbutils-1.0' found
Checking for module 'gstreamer-base-0.10'
  No package 'gstreamer-base-0.10' found
Checking for module 'gstreamer-video-0.10'
  No package 'gstreamer-video-0.10' found
Checking for module 'gstreamer-app-0.10'
  No package 'gstreamer-app-0.10' found
Checking for module 'gstreamer-riff-0.10'
  No package 'gstreamer-riff-0.10' found
Checking for module 'gstreamer-pbutils-0.10'
  No package 'gstreamer-pbutils-0.10' found
Looking for linux/videodev.h
Looking for linux/videodev.h - not found
Looking for linux/videodev2.h
Looking for linux/videodev2.h - found
Looking for sys/videoio.h
Looking for sys/videoio.h - not found
WARNING, PrimeSensor Module binaries directory (set by OPENNI_PRIME_SENSOR_MODULE_BIN_DIR variable) is not found or does not have PrimeSensor Module binaries.
Checking for module 'libavresample'
  No package 'libavresample' found
Checking for module 'libgphoto2'
  No package 'libgphoto2' found
Found TBB: /usr/lib/x86_64-linux-gnu/libtbb.so
found IPP (ICV version): 9.0.1 [9.0.1]
at: /home/ronjane92/Programs/opencv/opencv-3.2.0-build/3rdparty/ippicv/ippicv_lnx
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find Atlas (missing:  Atlas_CLAPACK_INCLUDE_DIR) 
Could NOT find JNI (missing:  JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

Found VTK ver. 6.2.0 (usefile: /usr/lib/cmake/vtk-6.2/UseVTK.cmake)
Caffe:   NO
Protobuf:   YES
Glog:   NO
freetype2:   YES
harfbuzz:    YES
Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
freetype2:   YES
harfbuzz:    YES
Checking for modules 'tesseract;lept'
  No package 'tesseract' found
  No package 'lept' found
Tesseract:   NO
Check contents of vgg_generated_48.i ...
Check contents of vgg_generated_64.i ...
Check contents of vgg_generated_80.i ...
Check contents of vgg_generated_120.i ...
Check contents of boostdesc_bgm.i ...
Check contents of boostdesc_bgm_bi.i ...
Check contents of boostdesc_bgm_hd.i ...
Check contents of boostdesc_binboost_064.i ...
Check contents of boostdesc_binboost_128.i ...
Check contents of boostdesc_binboost_256.i ...
Check contents of boostdesc_lbgm.i ...

General configuration for OpenCV 3.2.0 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            /home/ronjane92/Programs/opencv/opencv_contrib-3.2.0/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2017-09-16T18:20:02Z
    Host:                        Linux 4.8.0-58-generic x86_64
    CMake:                       3.5.1
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 5.4.0)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):
    Linker flags (Debug):
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:          Qt5::Test Qt5::Concurrent Qt5::OpenGL /usr/lib/x86_64-linux-gnu/libwebp.so /usr/lib/x86_64-linux-gnu/libjasper.so /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so dc1394 avcodec-ffmpeg avformat-ffmpeg avutil-ffmpeg swscale-ffmpeg /usr/lib/libOpenNI.so Qt5::Core Qt5::Gui Qt5::Widgets /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so /usr/lib/x86_64-linux-gnu/libpthread.so /usr/lib/x86_64-linux-gnu/libsz.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libm.so vtkRenderingOpenGL vtkImagingHybrid vtkIOImage vtkCommonDataModel vtkCommonMath vtkCommonCore vtksys vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkCommonExecutionModel vtkDICOMParser vtkIOCore /usr/lib/x86_64-linux-gnu/libz.so vtkmetaio /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libtiff.so vtkImagingCore vtkRenderingCore vtkCommonColor vtkFiltersExtraction vtkFiltersCore vtkFiltersGeneral vtkCommonComputationalGeometry vtkFiltersStatistics vtkImagingFourier vtkalglib vtkFiltersGeometry vtkFiltersSources vtkInteractionStyle vtkRenderingLOD vtkFiltersModeling vtkIOPLY vtkIOGeometry /usr/lib/x86_64-linux-gnu/libjsoncpp.so vtkFiltersTexture vtkRenderingFreeType /usr/lib/x86_64-linux-gnu/libfreetype.so vtkftgl vtkIOExport vtkRenderingAnnotation vtkImagingColor vtkRenderingContext2D vtkRenderingGL2PS vtkRenderingContextOpenGL /usr/lib/libgl2ps.so vtkRenderingLabel dl m pthread rt /usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so tbb
    3rdparty dependencies:       libprotobuf

  OpenCV modules:
    To be built:                 core flann hdf imgproc ml photo reg surface_matching video viz dnn freetype fuzzy imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib cvv datasets rgbd stereo tracking videostab xfeatures2d ximgproc aruco optflow phase_unwrapping stitching structured_light python2
    Disabled:                    world contrib_world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python3 cnn_3dobj matlab sfm

  Non-free algorithms are enabled

  GUI: 
    QT 5.x:                      YES (ver 5.5.1)
    QT OpenGL support:           YES (Qt5::OpenGL 5.5.1)
    OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so)
    VTK support:                 YES (ver 6.2.0)

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x0202)
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.6)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2.2.0)
    GDAL:                        NO
    GDCM:                        NO

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.4)
    FFMPEG:                      YES
      avcodec:                   YES (ver 56.60.100)
      avformat:                  YES (ver 56.40.101)
      avutil:                    YES (ver 54.31.100)
      swscale:                   YES (ver 3.1.101)
      avresample:                NO
    GStreamer:                   NO
    OpenNI:                      YES (ver 1.5.4, build 0)
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    Aravis SDK:                  NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    NO/YES
    XIMEA:                       NO
    Xine:                        NO
    gPhoto2:                     NO

  Parallel framework:            TBB (ver 4.4 interface 9002)

  Other third-party libraries:
    Use IPP:                     9.0.1 [9.0.1]
         at:                     /home/ronjane92/Programs/opencv/opencv-3.2.0-build/3rdparty/ippicv/ippicv_lnx
    Use IPP Async:               NO
    Use VA:                      NO
    Use Intel VA-API/OpenCL:     NO
    Use Lapack:                  NO
    Use Eigen:                   YES (ver 3.2.92)
    Use Cuda:                    NO
    Use OpenCL:                  YES
    Use OpenVX:                  NO
    Use custom HAL:              NO

  OpenCL:                        <Dynamic loading of OpenCL library>
    Include path:                /home/ronjane92/Programs/opencv/opencv-3.2.0-source/3rdparty/include/opencl/1.2
    Use AMDFFT:                  NO
    Use AMDBLAS:                 NO

  Python 2:
    Interpreter:                 /usr/bin/python2.7 (ver 2.7.12)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
    numpy:                       /home/ronjane92/.local/lib/python2.7/site-packages/numpy/core/include (ver 1.13.1)
    packages path:               lib/python2.7/dist-packages

  Python 3:
    Interpreter:                 /usr/bin/python3 (ver 3.5.2)

  Python (for build):            /usr/bin/python2.7

  Java:
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        Matlab not found or implicitly disabled

  Documentation:
    Doxygen:                     /usr/bin/doxygen (ver 1.8.11)

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  /usr/local

  cvconfig.h is in:              /home/ronjane92/Programs/opencv/opencv-3.2.0-build
-----------------------------------------------------------------

Configuring done
Generating done

This is a repeated question so I've tried to google for solutions but none of them worked in my situation. Anyone who can help me out? Those two lines of output when I tried to run the code are the only errors I got. No error appears when I make & make install OpenCV libs. Thanks.

Update: I get rid of Qt creator and only try to run the code in terminal. In the "build" folder I run cmake .. and the build is complete, when I run make, it shows

../lib/libslam_essentials.so: undefined reference to `cv::xfeatures2d::SURF::create(double, int, int, bool, bool)'
collect2: error: ld returned 1 exit status
src/CMakeFiles/opencv_test.dir/build.make:382: recipe for target 'bin/opencv_test' failed
make[2]: *** [bin/opencv_test] Error 1
CMakeFiles/Makefile2:87: recipe for target 'src/CMakeFiles/opencv_test.dir/all' failed
make[1]: *** [src/CMakeFiles/opencv_test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

OpenCV 3.2.0 cannnot access to SURF/SIFT in xfeatures2d

I am using Qt creator in Ubuntu 16.04 to build a non-Qt project. I need to use SIFT to detect features. I know that SIFT and SURF are in OpenCV_contrib so I add the extra module when using CMake-gui to configure OpenCV.

Then I can find libopencv_xfeatures2d.so/.so.3.2/.so.3.2.0 and also libopencv_features2d.so/.so.3.2/.so.3.2.0 in /usr/local/lib When I am using the code from OpenCV official website: test code to test SIFT, I still get the error

/home/ronjane92/Documents/Qt/OpenCV/build/lib/libslam_essentials.so:-1: error: undefined reference to `cv::xfeatures2d::SIFT::create(int, int, double, double, double)'

:-1: error: collect2: error: ld returned 1 exit status

My CMakeLists.txt has the following things:

    CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
    PROJECT(opencv_test)

    include( CheckCXXCompilerFlag )
    SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")

    FIND_PACKAGE( PCL 1.7 REQUIRED COMPONENTS common io visualization)
    ADD_DEFINITIONS( ${PCL_DEFINITIONS} )
    INCLUDE_DIRECTORIES( ${PCL_INCLUDE_DIRS} )
    LINK_DIRECTORIES( ${PCL_LIBRARY_DIRS} )

    ADD_SUBDIRECTORY(lib)
    INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib )
    LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/lib )

    FIND_PACKAGE( OpenCV 3.1.0 REQUIRED )
    INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} )

    ADD_EXECUTABLE(${PROJECT_NAME} "main.cpp")
    TARGET_LINK_LIBRARIES(opencv_test ${OpenCV_LIBRARIES}
                                      ${PCL_LIBRARIES}
                                      realsense
                                      slam_essentials
                         )

The results from Cmake-gui are
Detected version of GNU GCC: 54 (504)
FP16: Feature disabled
Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") 
Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") 
Found OpenEXR: /usr/lib/x86_64-linux-gnu/libIlmImf.so
Checking for module 'gstreamer-base-1.0'
  No package 'gstreamer-base-1.0' found
Checking for module 'gstreamer-video-1.0'
  No package 'gstreamer-video-1.0' found
Checking for module 'gstreamer-app-1.0'
  No package 'gstreamer-app-1.0' found
Checking for module 'gstreamer-riff-1.0'
  No package 'gstreamer-riff-1.0' found
Checking for module 'gstreamer-pbutils-1.0'
  No package 'gstreamer-pbutils-1.0' found
Checking for module 'gstreamer-base-0.10'
  No package 'gstreamer-base-0.10' found
Checking for module 'gstreamer-video-0.10'
  No package 'gstreamer-video-0.10' found
Checking for module 'gstreamer-app-0.10'
  No package 'gstreamer-app-0.10' found
Checking for module 'gstreamer-riff-0.10'
  No package 'gstreamer-riff-0.10' found
Checking for module 'gstreamer-pbutils-0.10'
  No package 'gstreamer-pbutils-0.10' found
Looking for linux/videodev.h
Looking for linux/videodev.h - not found
Looking for linux/videodev2.h
Looking for linux/videodev2.h - found
Looking for sys/videoio.h
Looking for sys/videoio.h - not found
WARNING, PrimeSensor Module binaries directory (set by OPENNI_PRIME_SENSOR_MODULE_BIN_DIR variable) is not found or does not have PrimeSensor Module binaries.
Checking for module 'libavresample'
  No package 'libavresample' found
Checking for module 'libgphoto2'
  No package 'libgphoto2' found
Found TBB: /usr/lib/x86_64-linux-gnu/libtbb.so
found IPP (ICV version): 9.0.1 [9.0.1]
at: /home/ronjane92/Programs/opencv/opencv-3.2.0-build/3rdparty/ippicv/ippicv_lnx
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find Atlas (missing:  Atlas_CLAPACK_INCLUDE_DIR) 
Could NOT find JNI (missing:  JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

Found VTK ver. 6.2.0 (usefile: /usr/lib/cmake/vtk-6.2/UseVTK.cmake)
Caffe:   NO
Protobuf:   YES
Glog:   NO
freetype2:   YES
harfbuzz:    YES
Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
freetype2:   YES
harfbuzz:    YES
Checking for modules 'tesseract;lept'
  No package 'tesseract' found
  No package 'lept' found
Tesseract:   NO
Check contents of vgg_generated_48.i ...
Check contents of vgg_generated_64.i ...
Check contents of vgg_generated_80.i ...
Check contents of vgg_generated_120.i ...
Check contents of boostdesc_bgm.i ...
Check contents of boostdesc_bgm_bi.i ...
Check contents of boostdesc_bgm_hd.i ...
Check contents of boostdesc_binboost_064.i ...
Check contents of boostdesc_binboost_128.i ...
Check contents of boostdesc_binboost_256.i ...
Check contents of boostdesc_lbgm.i ...

General configuration for OpenCV 3.2.0 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            /home/ronjane92/Programs/opencv/opencv_contrib-3.2.0/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2017-09-16T18:20:02Z
    Host:                        Linux 4.8.0-58-generic x86_64
    CMake:                       3.5.1
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 5.4.0)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):
    Linker flags (Debug):
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:          Qt5::Test Qt5::Concurrent Qt5::OpenGL /usr/lib/x86_64-linux-gnu/libwebp.so /usr/lib/x86_64-linux-gnu/libjasper.so /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so dc1394 avcodec-ffmpeg avformat-ffmpeg avutil-ffmpeg swscale-ffmpeg /usr/lib/libOpenNI.so Qt5::Core Qt5::Gui Qt5::Widgets /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so /usr/lib/x86_64-linux-gnu/libpthread.so /usr/lib/x86_64-linux-gnu/libsz.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libm.so vtkRenderingOpenGL vtkImagingHybrid vtkIOImage vtkCommonDataModel vtkCommonMath vtkCommonCore vtksys vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkCommonExecutionModel vtkDICOMParser vtkIOCore /usr/lib/x86_64-linux-gnu/libz.so vtkmetaio /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libtiff.so vtkImagingCore vtkRenderingCore vtkCommonColor vtkFiltersExtraction vtkFiltersCore vtkFiltersGeneral vtkCommonComputationalGeometry vtkFiltersStatistics vtkImagingFourier vtkalglib vtkFiltersGeometry vtkFiltersSources vtkInteractionStyle vtkRenderingLOD vtkFiltersModeling vtkIOPLY vtkIOGeometry /usr/lib/x86_64-linux-gnu/libjsoncpp.so vtkFiltersTexture vtkRenderingFreeType /usr/lib/x86_64-linux-gnu/libfreetype.so vtkftgl vtkIOExport vtkRenderingAnnotation vtkImagingColor vtkRenderingContext2D vtkRenderingGL2PS vtkRenderingContextOpenGL /usr/lib/libgl2ps.so vtkRenderingLabel dl m pthread rt /usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so tbb
    3rdparty dependencies:       libprotobuf

  OpenCV modules:
    To be built:                 core flann hdf imgproc ml photo reg surface_matching video viz dnn freetype fuzzy imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib cvv datasets rgbd stereo tracking videostab xfeatures2d ximgproc aruco optflow phase_unwrapping stitching structured_light python2
    Disabled:                    world contrib_world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python3 cnn_3dobj matlab sfm

  Non-free algorithms are enabled

  GUI: 
    QT 5.x:                      YES (ver 5.5.1)
    QT OpenGL support:           YES (Qt5::OpenGL 5.5.1)
    OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so)
    VTK support:                 YES (ver 6.2.0)

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x0202)
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.6)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2.2.0)
    GDAL:                        NO
    GDCM:                        NO

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.4)
    FFMPEG:                      YES
      avcodec:                   YES (ver 56.60.100)
      avformat:                  YES (ver 56.40.101)
      avutil:                    YES (ver 54.31.100)
      swscale:                   YES (ver 3.1.101)
      avresample:                NO
    GStreamer:                   NO
    OpenNI:                      YES (ver 1.5.4, build 0)
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    Aravis SDK:                  NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    NO/YES
    XIMEA:                       NO
    Xine:                        NO
    gPhoto2:                     NO

  Parallel framework:            TBB (ver 4.4 interface 9002)

  Other third-party libraries:
    Use IPP:                     9.0.1 [9.0.1]
         at:                     /home/ronjane92/Programs/opencv/opencv-3.2.0-build/3rdparty/ippicv/ippicv_lnx
    Use IPP Async:               NO
    Use VA:                      NO
    Use Intel VA-API/OpenCL:     NO
    Use Lapack:                  NO
    Use Eigen:                   YES (ver 3.2.92)
    Use Cuda:                    NO
    Use OpenCL:                  YES
    Use OpenVX:                  NO
    Use custom HAL:              NO

  OpenCL:                        <Dynamic loading of OpenCL library>
    Include path:                /home/ronjane92/Programs/opencv/opencv-3.2.0-source/3rdparty/include/opencl/1.2
    Use AMDFFT:                  NO
    Use AMDBLAS:                 NO

  Python 2:
    Interpreter:                 /usr/bin/python2.7 (ver 2.7.12)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
    numpy:                       /home/ronjane92/.local/lib/python2.7/site-packages/numpy/core/include (ver 1.13.1)
    packages path:               lib/python2.7/dist-packages

  Python 3:
    Interpreter:                 /usr/bin/python3 (ver 3.5.2)

  Python (for build):            /usr/bin/python2.7

  Java:
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        Matlab not found or implicitly disabled

  Documentation:
    Doxygen:                     /usr/bin/doxygen (ver 1.8.11)

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  /usr/local

  cvconfig.h is in:              /home/ronjane92/Programs/opencv/opencv-3.2.0-build
-----------------------------------------------------------------

Configuring done
Generating done

This is a repeated question so I've tried to google for solutions but none of them worked in my situation. Anyone who can help me out? Those two lines of output when I tried to run the code are the only errors I got. No error appears when I make & make install OpenCV libs. Thanks.

Update: In the ~/Documents/test_SIFT, I have build , src folders and CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(opencv_test)

include( CheckCXXCompilerFlag )
SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")

SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

ADD_SUBDIRECTORY( ${PROJECT_SOURCE_DIR}/src)

In the src folder, I have lib folder, main.cpp and CMakeLists.txt

ADD_SUBDIRECTORY(lib)
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/lib )
LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/lib )

FIND_PACKAGE( OpenCV 3.1.0 REQUIRED )
INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} )

ADD_EXECUTABLE(${PROJECT_NAME} "main.cpp")
TARGET_LINK_LIBRARIES(opencv_test ${OpenCV_LIBRARIES}
                                  ${PCL_LIBRARIES}
                                  realsense
                                  slam_essentials
                                  )

In the lib folder, I have lots of header and source files and a CMakeLists.txt

SET( LIBSLAM_SRC timeloop.cpp
                 configrscamera.cpp
                 createpointcloudviewer.cpp
                 generatepointcloud.cpp
                 splicepointcloud.cpp
                 help.cpp
                 )

SET( LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib )

ADD_LIBRARY( slam_essentials SHARED ${LIBSLAM_SRC})

I get rid of Qt creator and only try to run the code in terminal. In the "build" folder I run cmake .. and the build it is complete, when I run make, it shows

../lib/libslam_essentials.so: undefined reference to `cv::xfeatures2d::SURF::create(double, int, int, bool, bool)'
collect2: error: ld returned 1 exit status
src/CMakeFiles/opencv_test.dir/build.make:382: recipe for target 'bin/opencv_test' failed
make[2]: *** [bin/opencv_test] Error 1
CMakeFiles/Makefile2:87: recipe for target 'src/CMakeFiles/opencv_test.dir/all' failed
make[1]: *** [src/CMakeFiles/opencv_test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2