i study opencv toturials,have a problem
first:i create file DisplayImage.cpp and CMakeLists.txt file
DisplayImage.cpp content :
include <stdio.h>
include <opencv2 opencv.hpp="">
using namespace cv; int main(int argc, char** argv ) { if ( argc != 2 ) { printf("usage: DisplayImage.out <image_path>\n"); return -1; } Mat image; image = imread( argv[1], 1 ); if ( !image.data ) { printf("No image data \n"); return -1; } namedWindow("Display Image", WINDOW_AUTOSIZE ); imshow("Display Image", image); waitKey(0); return 0; }
CMakeLists.txt file content: cmake_minimum_required(VERSION 2.8) project( DisplayImage ) find_package( OpenCV REQUIRED ) include_directories( ${OpenCV_INCLUDE_DIRS} ) add_executable( DisplayImage DisplayImage.cpp ) target_link_libraries( DisplayImage ${OpenCV_LIBS} )
second i input .make on my terminal (tensorflow) chentao@thinkPad:~/opencv$ cmake . -- The C compiler identification is GNU 5.5.0 -- The CXX compiler identification is GNU 4.8.5 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found OpenCV: /home/chentao/anaconda3/envs/tensorflow (found version "3.4.1") -- Configuring done -- Generating done -- Build files have been written to: /home/chentao/opencv
Third i input make on terminal
(tensorflow) chentao@thinkPad:~/opencv$ make
Scanning dependencies of target DisplayImage
[ 50%] Building CXX object CMakeFiles/DisplayImage.dir/DisplayImage.cpp.o
[100%] Linking CXX executable DisplayImage
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to VTT for std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to
std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::reserve(unsigned long)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to
std::__cxx11::basic_ostringstream<char, std::char_traits<char="">, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::resize(unsigned long, char)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to
vtable for std::__cxx11::basic_ostringstream<char, std::char_traits<char="">, std::allocator<char> >@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to
std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> >::compare(std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> > const&) const@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char, unsigned long) const@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to
std::__cxx11::basic_stringstream<char, std::char_traits<char="">, std::allocator<char> >::~basic_stringstream()@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(char const*)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to
vtable for std::__cxx11::basic_stringstream<char, std::char_traits<char="">, std::allocator<char> >@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to vtable for std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to
std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> >::_M_create(unsigned long&, unsigned long)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace_aux(unsigned long, unsigned long, unsigned long, char)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to
std::basic_istream<char, std::char_traits<char=""> >& std::getline<char, std::char_traits<char="">, std::allocator<char> >(std::basic_istream<char, std::char_traits<char=""> >&, std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> >&, char)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::_M_sync(char*, unsigned long, unsigned long)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to
std::__cxx11::basic_stringstream<char, std::char_traits<char="">, std::allocator<char> >::basic_stringstream(std::_Ios_Openmode)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to
std::__cxx11::basic_ostringstream<char, std::char_traits<char="">, std::allocator<char> >::~basic_ostringstream()@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to vtable for std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to
std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> >::compare(char const) const@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to
VTT for std::__cxx11::basic_ostringstream<char, std::char_traits<char="">, std::allocator<char> >@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_istringstream()@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to
VTT for std::__cxx11::basic_istringstream<char, std::char_traits<char="">, std::allocator<char> >@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_core.so.3.4.1: undefined reference to
std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const, unsigned long)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to
std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> >::find(char const, unsigned long, unsigned long) const@GLIBCXX_3.4.21'
/home/chentao/anaconda3/envs/tensorflow/lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> >::rfind(char, unsigned long) const@GLIBCXX_3.4.21'
collect2: error: ld returned 1 exit status
make[2]: [DisplayImage] Error 1
make[1]: [CMakeFiles/DisplayImage.dir/all] Error 2
make: ** [all] Error 2
please help me , thanks advantaged T^T