Unable to execute the sample program

asked 2019-10-31 00:23:29 -0600

karthikkarra gravatar image

updated 2019-10-31 03:43:41 -0600

I am facing undefined reference error while executing opencv_version.cpp. The command I am using is g++ -ggdb -std=c++11 opencv_version.cpp -o /tmp/opencv_version 'pkg-config --cflags --libs opencv4'.

and the CMAKE command I am using is

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/ubuntu/opencv-4.0.0/build -D INSTALL_C_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D OPENCV_GENERATE_PKGCONFIG=ON -D OPENCV_EXTRA_MODULES_PATH=/home/ubuntu/opencv_contrib-4.0.0/modules ../

Below are the set of errors I am facing.

/tmp/ccoM18qB.o: In function `main': /home/ubuntu/opencv-4.0.0/samples/cpp/opencv_version.cpp:13: undefined reference to `cv::CommandLineParser::CommandLineParser(int, char const* const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'                                                                                        /home/ubuntu/opencv-4.0.0/samples/cpp/opencv_version.cpp:14: undefined reference to `cv::CommandLineParser::about(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'                                                                                                                                                          /home/ubuntu/opencv-4.0.0/samples/cpp/opencv_version.cpp:15: undefined reference to `cv::CommandLineParser::has(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'                                                                                                                                            /home/ubuntu/opencv-4.0.0/samples/cpp/opencv_version.cpp:17: undefined reference to `cv::CommandLineParser::printMessage() const'                                                                                                             /home/ubuntu/opencv-4.0.0/samples/cpp/opencv_version.cpp:19: undefined reference to `cv::CommandLineParser::check() const'                                                                                                         /home/ubuntu/opencv-4.0.0/samples/cpp/opencv_version.cpp:21: undefined reference to `cv::CommandLineParser::printErrors() const'                                                                                                   /home/ubuntu/opencv-4.0.0/samples/cpp/opencv_version.cpp:23: undefined reference to `cv::CommandLineParser::has(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'                                                                                                                                           /home/ubuntu/opencv-4.0.0/samples/cpp/opencv_version.cpp:25: undefined reference to `cv::getBuildInformation[abi:cxx11]()'                                                                                                               /home/ubuntu/opencv-4.0.0/samples/cpp/opencv_version.cpp:13: undefined reference to `cv::CommandLineParser::~CommandLineParser()'                                                                                        /home/ubuntu/opencv-4.0.0/samples/cpp/opencv_version.cpp:13: undefined reference to `cv::CommandLineParser::~CommandLineParser()'                                                                                            collect2: error: ld returned 1 exit status

I have gone through some sites all were mentioning about using the above command but its of no use.

edit retag flag offensive close merge delete

Comments

1

helo, please be so kind and change the screenshot to a TEXT version, thank you.

berak gravatar imageberak ( 2019-10-31 02:35:00 -0600 )edit
2

I have changed to text and even updated with the CMAKE command

karthikkarra gravatar imagekarthikkarra ( 2019-10-31 03:45:17 -0600 )edit