libopencv_calib3d:对`std :: __ throw_out_of_range_fmt(char const *,…)@ GLIBCXX_3.4.20'的未定义引用 [英] libopencv_calib3d: undefined reference to `std::__throw_out_of_range_fmt(char const*, …)@GLIBCXX_3.4.20'
问题描述
我提到此来安装OpenCV在我的Raspberry Pi 2(在最新的Raspbian内核版本4.1.7-v7上运行)上运行.由于存在依赖项错误,我无法安装libgtk2.0-dev,但没有任何错误,我能够安装OpenCV.
I referred to this 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.
我正在尝试为我的Raspberry Pi 2在Qt中交叉编译一些简单的OpenCV代码.但是在链接器阶段出现以下错误:
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:
/usr/local/lib/libopencv_calib3d.so: undefined reference to
std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20
我的代码是:
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 (/*condition*/) {
break;
}
}
}
我尝试更改链接库的顺序.但是错误仍然存在.我的.pro
文件看起来是这样的:
I tried changing the order in which the libraries are linked. But the error still remains. My .pro
file looks 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 */
我该如何解决?
更新
我设法安装libgtk2.0-dev并再次编译OpenCV.但是错误仍然存在.
I managed to install libgtk2.0-dev and compile OpenCV again. But the error remains.
推荐答案
我也有同样的经历.我假设您正在使用 https://github.com/raspberrypi/tools 作为工具链,但是即使您不是问题所在,无论您使用的是哪种工具链,都可能早于gcc/g ++ 4.9.
I've had the same experience. I'm assuming you are using https://github.com/raspberrypi/tools as your toolchain, but even if you are not the problem is that whatever toolchain you are using it probably predates gcc/g++ 4.9.
问题在于Jessie(即Raspbian 4.1.X)使用gcc/g ++ 4.9作为其工具链,而OpenCV正在使用该编译器版本的新STL功能.因此,如果您的应用程序是使用早于gcc/g ++ 4.9的工具链构建的,则它将不会链接.
The problem is that Jessie (i.e. Raspbian 4.1.X) uses gcc/g++ 4.9 as its toolchain and OpenCV is making use of an STL feature that is new to that version of the compiler. Therefore if your application is built with a toolchain that predates gcc/g++ 4.9, it will not link.
解决方案是获取至少4.9或更高版本的工具链,或者坚持使用gcc 4.6的Whaspy版本的Raspbian.
The solution is to either get a toolchain that is at least 4.9 or greater, or stick with the Wheezy release of Raspbian, which uses gcc 4.6.
我在以下文章中详细介绍了交叉编译OpenCV应用程序的经验:
I detailed my experience with cross compiling an OpenCV app in a post here: https://solderspot.wordpress.com/2016/02/04/cross-compiling-for-raspberry-pi-part-ii.
希望对您有所帮助.
这篇关于libopencv_calib3d:对`std :: __ throw_out_of_range_fmt(char const *,…)@ GLIBCXX_3.4.20'的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!