I mentioned this to install OpenCV on my Raspberry Pi 2 (which works on the latest Raspbian with the 4.1.7-v7 kernel release). I was unable to install libgtk2.0-dev due to dependency errors, but I was able to install OpenCV without any errors.
I am trying to cross-compile simple OpenCV code in Qt for my raspberry Pi 2. But at the linker stage, I get the following error:
/usr/local/lib/libopencv_calib3d.so: undefined reference to
std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20
My code is:
myFunc {
VideoCapture cap(0);
if (!cap.isOpened()) {
qDebug() << "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() << "Frame size : " << dWidth << " x " << dHeight;
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE);
while (1) {
Mat frame;
bool bSuccess = cap.read(frame);
if (!bSuccess) {
qDebug() << "Cannot read a frame from video stream";
break;
}
imshow("MyVideo", frame);
if () {
break;
}
}
}
I tried changing the order in which the libraries are linked. But the error still persists. My file .pro
looks like this:
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 */
How can i solve this?
UPDATE
I managed to install libgtk2.0-dev and compile OpenCV again. But the error remains.