Ask Your Question
0

I found this error while running sample cpp example facedetect.cpp 'undefiend reference to cv:

asked 2017-07-12 06:00:41 -0600

I am Dev gravatar image

updated 2019-12-09 08:01:57 -0600

Akhil Patel gravatar image
/tmp/ccbH13my.o: In function main': facedetect.cpp:(.text+0x10e): undefined reference tocv::VideoCapture::VideoCapture()'
facedetect.cpp:(.text+0x14a): undefined reference to cv::CascadeClassifier::CascadeClassifier()' facedetect.cpp:(.text+0x159): undefined reference tocv::CascadeClassifier::CascadeClassifier()'
facedetect.cpp:(.text+0x192): undefined reference to cv::CommandLineParser::CommandLineParser(int, char const* const*, cv::String const&)' facedetect.cpp:(.text+0x1d0): undefined reference tocv::CommandLineParser::has(cv::String const&) const'
facedetect.cpp:(.text+0x36c): undefined reference to cv::CommandLineParser::has(cv::String const&) const' facedetect.cpp:(.text+0x3ff): undefined reference tocv::CommandLineParser::check() const'
facedetect.cpp:(.text+0x415): undefined reference to cv::CommandLineParser::printErrors() const' facedetect.cpp:(.text+0x44e): undefined reference tocv::CascadeClassifier::load(cv::String const&)'
facedetect.cpp:(.text+0x4bd): undefined reference to cv::CascadeClassifier::load(cv::String const&)' facedetect.cpp:(.text+0x5be): undefined reference tocv::VideoCapture::open(int)'
facedetect.cpp:(.text+0x66c): undefined reference to cv::imread(cv::String const&, int)' facedetect.cpp:(.text+0x6ec): undefined reference tocv::VideoCapture::open(cv::String const&)'
facedetect.cpp:(.text+0x77e): undefined reference to cv::imread(cv::String const&, int)' facedetect.cpp:(.text+0x7ff): undefined reference tocv::VideoCapture::isOpened() const'
facedetect.cpp:(.text+0x836): undefined reference to cv::VideoCapture::operator>>(cv::Mat&)' facedetect.cpp:(.text+0x8c3): undefined reference tocv::waitKey(int)'
facedetect.cpp:(.text+0x9b3): undefined reference to cv::waitKey(int)' facedetect.cpp:(.text+0xafa): undefined reference tocv::imread(cv::String const&, int)'
facedetect.cpp:(.text+0xb8b): undefined reference to cv::waitKey(int)' facedetect.cpp:(.text+0xc19): undefined reference tocv::CommandLineParser::~CommandLineParser()'
facedetect.cpp:(.text+0xc28): undefined reference to cv::CascadeClassifier::~CascadeClassifier()' facedetect.cpp:(.text+0xc37): undefined reference tocv::CascadeClassifier::~CascadeClassifier()'
facedetect.cpp:(.text+0xc73): undefined reference to cv::VideoCapture::~VideoCapture()' facedetect.cpp:(.text+0xe0e): undefined reference tocv::CommandLineParser::~CommandLineParser()'
facedetect.cpp:(.text+0xe22): undefined reference to cv::CascadeClassifier::~CascadeClassifier()' facedetect.cpp:(.text+0xe36): undefined reference tocv::CascadeClassifier::~CascadeClassifier()'
facedetect.cpp:(.text+0xe77): undefined reference to cv::VideoCapture::~VideoCapture()' /tmp/ccbH13my.o: In functiondetectAndDraw(cv::Mat&, cv::CascadeClassifier&, cv::CascadeClassifier&, double, bool)':
facedetect.cpp:(.text+0x1123): undefined reference to cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)' facedetect.cpp:(.text+0x11de): undefined reference tocv::resize(cv::_InputArray const&, cv::OutputArray const&, cv::Size, double, double, int)'
facedetect.cpp:(.text+0x1247): undefined reference to cv::equalizeHist(cv::_InputArray const&, cv::_OutputArray const&)' facedetect.cpp:(.text+0x126a): undefined reference tocv::getTickCount()'
facedetect.cpp:(.text+0x1310): undefined reference to cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)' facedetect.cpp:(.text+0x1380): undefined reference tocv::flip(cv::InputArray const&, cv::OutputArray const&, int)'
facedetect.cpp:(.text+0x1433): undefined reference to cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)' facedetect.cpp:(.text+0x155f): undefined reference tocv::getTickCount()'
facedetect.cpp:(.text+0x1599): undefined reference to cv::getTickFrequency()' facedetect.cpp:(.text+0x17dc): undefined reference tocv::circle(cv::InputOutputArray const&, cv::Point, int, cv::Scalar const&, int, int, int)'
facedetect ...
(more)
edit retag flag offensive close merge delete

Comments

I am not sure but there may be problem with linker.

vps gravatar imagevps ( 2017-07-12 06:13:22 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-12 06:11:15 -0600

berak gravatar image

you are not linking any required opencv libraries. try like:

g++ myprog.cpp -lopencv_core -lopencv_imgproc -lopencv_videoio -lopencv_highgui -lopencv_objdetect -o myprog
edit flag offensive delete link more

Comments

After trying this command it showing me different error

/usr/bin/ld: /tmp/ccLWBUKG.o: undefined reference to symbol '_ZN2cv6imreadERKNS_6StringEi'
//usr/local/lib/libopencv_imgcodecs.so.3.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I am Dev gravatar imageI am Dev ( 2017-07-17 05:33:37 -0600 )edit

add -lopencv_imgcodecs to the list.

your 1st ever c++ program ?

berak gravatar imageberak ( 2017-07-17 05:35:20 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-07-12 06:00:41 -0600

Seen: 2,764 times

Last updated: Jul 12 '17