Building Opencv using c++ error: undefined reference to `cv::Mat::deallocate()'

37 views Asked by At

I have configured my OpenCV successfully from OpenCV official code version 4.2.0 with the command as below:

pkg-config --cflags --libs opencv

The output after the configuration is as:

-I/home/blaster/installed/include/opencv4/opencv -I/home/blaster/installed/include/opencv4 -L/home/blaster/installed/lib -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_highgui -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core

And after configuration, I tried to run the code on my device which has Ubuntu 20.04.1 with the following command:

g++ `pkg-config --cflags --libs opencv` prog.cpp

And got this error:

    cv::VideoCapture::VideoCapture(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
    /usr/bin/ld: prog.cpp:(.text+0x89): undefined reference to `cv::VideoCapture::isOpened() const'
    /usr/bin/ld: prog.cpp:(.text+0xc1): undefined reference to `cv::VideoCapture::get(int) const'
    /usr/bin/ld: prog.cpp:(.text+0x107): undefined reference to `cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
    /usr/bin/ld: prog.cpp:(.text+0x15d): undefined reference to `cv::VideoCapture::read(cv::_OutputArray const&)'
    /usr/bin/ld: prog.cpp:(.text+0x1ed): undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
    /usr/bin/ld: prog.cpp:(.text+0x224): undefined reference to `cv::waitKey(int)'
    /usr/bin/ld: prog.cpp:(.text+0x264): undefined reference to `cv::VideoCapture::~VideoCapture()'
    /usr/bin/ld: prog.cpp:(.text+0x363): undefined reference to `cv::VideoCapture::~VideoCapture()'
    /usr/bin/ld: /tmp/cc6PCHzq.o: in function `cv::Mat::~Mat()':
    prog.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x3d): undefined reference to `cv::fastFree(void*)'
    /usr/bin/ld: /tmp/cc6PCHzq.o: in function `cv::Mat::release()':
    prog.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4f): undefined reference to `cv::Mat::deallocate()'
    collect2: error: ld returned 1 exit status

How to resolve this?

0

There are 0 answers