mingw编译opencv2.4.13问题记录

2018-06-17 22:44:17来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

为了在程序中用regex,升级了我的mingw,结果官网上的GCC版本都到6.3了,之前一直用4.8。换了编译器以后,对opencv2.4.10的引用就出了问题:undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)',所以尝试使用新的编译器编译opencv,顺便也把opencv升级到2.4.13。

使用mingw64的32位版本编译opencv,默认配置。gcc version 6.3.0
编译过程中出错,报:
error: unrecognized command line option '-sse2'; did you mean '-msse2'?
搜索无果,在makefile中找到这一行,放在命令行中执行,发现缺少一个头文件的包含路径,加上以后重新在命令行执行,编译成功,继续make
g++ -O2 -DNDEBUG -DNDEBUG -I"D:/software/opencv/opencv-2.4.13/modules/gpu/perf" -I"D:/software/opencv/opencv-2.4.13/modules/video/include" -I"D:/software/opencv/opencv-2.4.13/modules/calib3d/include" -I"D:/software/opencv/opencv-2.4.13/modules/features2d/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/imgproc/include" -I"D:/software/opencv/opencv-2.4.13/modules/flann/include" -I"D:/software/opencv/opencv-2.4.13/modules/core/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/ts/include" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/include" -I"D:/software/opencv/opencv-2.4.13/modules/photo/include" -I"D:/software/opencv/opencv-2.4.13/modules/objdetect/include" -I"D:/software/opencv/opencv-2.4.13/modules/legacy/include" -I"D:/software/opencv/opencv-2.4.13/modules/video/include" -I"D:/software/opencv/opencv-2.4.13/modules/ml/include" -I"D:/software/opencv/opencv-2.4.13/modules/calib3d/include" -I"D:/software/opencv/opencv-2.4.13/modules/features2d/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/imgproc/include" -I"D:/software/opencv/opencv-2.4.13/modules/flann/include" -I"D:/software/opencv/opencv-2.4.13/modules/core/include" -isystem"D:/software/opencv/opencv2.4.13mingw/modules/gpu" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/src" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/include" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/test" -I"D:/software/opencv/opencv-2.4.13/modules/video/include" -I"D:/software/opencv/opencv-2.4.13/modules/calib3d/include" -I"D:/software/opencv/opencv-2.4.13/modules/features2d/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/imgproc/include" -I"D:/software/opencv/opencv-2.4.13/modules/flann/include" -I"D:/software/opencv/opencv-2.4.13/modules/core/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/ts/include" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/include" -I"D:/software/opencv/opencv-2.4.13/modules/photo/include" -I"D:/software/opencv/opencv-2.4.13/modules/objdetect/include" -I"D:/software/opencv/opencv-2.4.13/modules/legacy/include" -I"D:/software/opencv/opencv-2.4.13/modules/video/include" -I"D:/software/opencv/opencv-2.4.13/modules/ml/include" -I"D:/software/opencv/opencv-2.4.13/modules/calib3d/include" -I"D:/software/opencv/opencv-2.4.13/modules/features2d/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/imgproc/include" -I"D:/software/opencv/opencv-2.4.13/modules/flann/include" -I"D:/software/opencv/opencv-2.4.13/modules/core/include" -isystem"D:/software/opencv/opencv2.4.13mingw/modules/gpu" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/src" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/include" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/src/cuda" -I"D:/software/opencv/opencv-2.4.13/modules/photo/include" -I"D:/software/opencv/opencv-2.4.13/modules/objdetect/include" -I"D:/software/opencv/opencv-2.4.13/modules/legacy/include" -I"D:/software/opencv/opencv-2.4.13/modules/video/include" -I"D:/software/opencv/opencv-2.4.13/modules/ml/include" -I"D:/software/opencv/opencv-2.4.13/modules/calib3d/include" -I"D:/software/opencv/opencv-2.4.13/modules/features2d/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/imgproc/include" -I"D:/software/opencv/opencv-2.4.13/modules/flann/include" -I"D:/software/opencv/opencv-2.4.13/modules/core/include" -isystem"D:/software/opencv/opencv2.4.13mingw/modules/gpu" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/src" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/include" -isystem"D:/software/opencv/opencv2.4.13mingw" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/perf" -I"D:/software/opencv/opencv-2.4.13/modules/video/include" -I"D:/software/opencv/opencv-2.4.13/modules/calib3d/include" -I"D:/software/opencv/opencv-2.4.13/modules/features2d/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/imgproc/include" -I"D:/software/opencv/opencv-2.4.13/modules/flann/include" -I"D:/software/opencv/opencv-2.4.13/modules/core/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/ts/include" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/include" -I"D:/software/opencv/opencv-2.4.13/modules/photo/include" -I"D:/software/opencv/opencv-2.4.13/modules/objdetect/include" -I"D:/software/opencv/opencv-2.4.13/modules/legacy/include" -I"D:/software/opencv/opencv-2.4.13/modules/video/include" -I"D:/software/opencv/opencv-2.4.13/modules/ml/include" -I"D:/software/opencv/opencv-2.4.13/modules/calib3d/include" -I"D:/software/opencv/opencv-2.4.13/modules/features2d/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/imgproc/include" -I"D:/software/opencv/opencv-2.4.13/modules/flann/include" -I"D:/software/opencv/opencv-2.4.13/modules/core/include" -isystem"D:/software/opencv/opencv2.4.13mingw/modules/gpu" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/src" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/include" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/test" -I"D:/software/opencv/opencv-2.4.13/modules/video/include" -I"D:/software/opencv/opencv-2.4.13/modules/calib3d/include" -I"D:/software/opencv/opencv-2.4.13/modules/features2d/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/imgproc/include" -I"D:/software/opencv/opencv-2.4.13/modules/flann/include" -I"D:/software/opencv/opencv-2.4.13/modules/core/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/ts/include" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/include" -I"D:/software/opencv/opencv-2.4.13/modules/photo/include" -I"D:/software/opencv/opencv-2.4.13/modules/objdetect/include" -I"D:/software/opencv/opencv-2.4.13/modules/legacy/include" -I"D:/software/opencv/opencv-2.4.13/modules/video/include" -I"D:/software/opencv/opencv-2.4.13/modules/ml/include" -I"D:/software/opencv/opencv-2.4.13/modules/calib3d/include" -I"D:/software/opencv/opencv-2.4.13/modules/features2d/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/imgproc/include" -I"D:/software/opencv/opencv-2.4.13/modules/flann/include" -I"D:/software/opencv/opencv-2.4.13/modules/core/include" -isystem"D:/software/opencv/opencv2.4.13mingw/modules/gpu" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/src" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/include" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/src/cuda" -I"D:/software/opencv/opencv-2.4.13/modules/photo/include" -I"D:/software/opencv/opencv-2.4.13/modules/objdetect/include" -I"D:/software/opencv/opencv-2.4.13/modules/legacy/include" -I"D:/software/opencv/opencv-2.4.13/modules/video/include" -I"D:/software/opencv/opencv-2.4.13/modules/ml/include" -I"D:/software/opencv/opencv-2.4.13/modules/calib3d/include" -I"D:/software/opencv/opencv-2.4.13/modules/features2d/include" -I"D:/software/opencv/opencv-2.4.13/modules/highgui/include" -I"D:/software/opencv/opencv-2.4.13/modules/imgproc/include" -I"D:/software/opencv/opencv-2.4.13/modules/flann/include" -I"D:/software/opencv/opencv-2.4.13/modules/core/include" -isystem"D:/software/opencv/opencv2.4.13mingw/modules/gpu" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/src" -I"D:/software/opencv/opencv-2.4.13/modules/gpu/include" -I"D:/software/opencv/opencv2.4.13mingw" -isystem"D:/software/opencv/opencv2.4.13mingw" -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-array-bounds -Wno-aggressive-loop-optimizations -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -x c++-header -o D:/software/opencv/opencv2.4.13mingw/modules/gpu/perf_precomp.hpp.gch/opencv_perf_gpu_Release.gch D:/software/opencv/opencv2.4.13mingw/modules/gpu/perf_precomp.hpp
然后出了错误:
error: '::hypot' has not been
查了此链接:
http://blog.csdn.net/a3335581/article/details/68583030
和http://stackoverflow.com/questions/28683358/error-hypot-has-not-been-declared-in-cmath-while-trying-to-embed-python
都说要在include Python前include cmath,所以在:
\opencv-2.4.13\modules\python\src2\cv2.cpp 文件中加了一句:
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
// eliminating duplicated round() declaration
#define HAVE_ROUND 1
#endif
#include <cmath>
#include <Python.h>
但是不管用,通过查看错误提示:
In file included from C:/Python27/include/Python.h:8:0,
from D:\software\opencv\opencv-2.4.13\modules\python\src2\cv2.cpp:6:
C:/msys32/mingw32/include/c++/6.3.0/math.h:91:12: error: 'std::_hypot' has not been declared
using std::hypot;
^
认为应该加include math.h
所以将cmath改成:
#include <math.h>
以后,错误消除。

然后发生了错误:
libpython27.a: error adding symbols: File format not recognized
搜索说是要将libpython27.a移出C:\Python27\libs文件夹,然后将python27.dll文件放入此文件夹,然后下载gendef.exe
gendef python27.dll
dlltool --as-flags=--32 --dllname python27.dll --def python27.def --output-lib libpython27.a -m i386
创建一个正确的libpython27.a ,每一个object 都是32-bit.
然后就编译成功了。

用新的opencv做程序,结果之前存在的问题还是存在,于是白弄了

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:51Node 1051---最大子矩阵和

下一篇:第一站:CLion安装教程与环境配置