title: libopencv_calib3d: undefined reference to `std::__throw_out_of_range_fmt(char const*, …)@GLIBCXX_3.4.20'
body: <p>I referred to <a href="http://robertcastle.com/2014/02/installing-opencv-on-a-raspberry-pi/" rel="noreferrer">this</a> to install OpenCV on my Raspberry Pi 2 (which is running on the latest Raspbian with kernel release 4.1.7-v7). I was not able to install libgtk2.0-dev due to dependency errors but I was able to install OpenCV without any errors.</p>
  
  <p>I am trying to cross-compile some simple OpenCV code in Qt for my Raspberry Pi 2. But I am getting the following error at linker stage:</p>
  
  <pre class="lang-none prettyprint-override"><code>/usr/local/lib/libopencv_calib3d.so: undefined reference to
  std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20
  </code></pre>
  
  <p>My code is:</p>
  
  <pre><code>myFunc {
      VideoCapture cap(0);
      if (!cap.isOpened()) {
          qDebug() &lt;&lt; "Cannot open the video cam";
          return;
      }
  
      double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH);
      double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
      qDebug() &lt;&lt; "Frame size : " &lt;&lt; dWidth &lt;&lt; " x " &lt;&lt; dHeight;
      namedWindow("MyVideo",CV_WINDOW_AUTOSIZE);
  
      while (1) {
          Mat frame;
          bool bSuccess = cap.read(frame);
  
           if (!bSuccess) {
               qDebug() &lt;&lt; "Cannot read a frame from video stream";
               break;
           }
  
           imshow("MyVideo", frame);
  
           if (/*condition*/) {
              break; 
           }
      }
  }
  </code></pre>
  
  <p>I tried changing the order in which the libraries are linked. But the error still remains. My <code>.pro</code> file looks this:</p>
  
  <pre><code>QT       += core gui quick xml widgets
  TARGET = myApp
  TEMPLATE = app
  
      QMAKE_CXXFLAGS += -I/mnt/rasp-pi-rootfs/usr/include \
                        -I/mnt/rasp-pi-rootfs/usr/include/libxml2 \
                        -I/mnt/rasp-pi-rootfs/usr/include/glib-2.0/glib \
                        -I/mnt/rasp-pi-rootfs/usr/include/glib-2.0 \
                        -I/mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/glib-2.0 \
                        -I/mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/glib-2.0/include \
                        -I/mnt/rasp-pi-rootfs/usr/include/gstreamer-1.0 \
                        -I/mnt/rasp-pi-rootfs/usr/local/include \
  
      QMAKE_CXXFLAGS += -Wno-psabi
  
      QMAKE_LIBDIR_FLAGS += -L/mnt/rasp-pi-rootfs/usr/lib \
                            -L/mnt/rasp-pi-rootfs/lib \
                            -L/mnt/rasp-pi-rootfs/usr/local/lib \
  
      QMAKE_LFLAGS   += -lgmodule-2.0 \
                        -lz \
                        -lxml2 \
                        -lgthread-2.0 \
                        -lrt \
                        -lglib-2.0 \
                        -lpthread \
                        -lgstreamer-1.0 \
                        -lgobject-2.0 \
                        -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_ts -lopencv_video \
  
  SOURCES += /* all .cpp files */
  
  HEADERS += /* all .h files */
  </code></pre>
  
  <p>How can I resolve this?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I managed to install libgtk2.0-dev and compile OpenCV again. But the error remains.</p>