mingw编译opencv2.4.13问题记录

为了在程序中用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做程序,结果之前存在的问题还是存在,于是白弄了

时间: 2024-09-29 11:29:02

mingw编译opencv2.4.13问题记录的相关文章

MinGW+CMake编译Opencv2.4.10

安装MinGW 下载地址:http://www.mingw.org 安装:运行mingw-get-setup.exe 选择安装mingw32-base   mingw32-gcc-g++ 将mingw的bin目录添加到环境变量 安装CMake 下载地址:http://www.cmake.org 安装:双击cmake-3.0.2-win32-x86.exe进行安装 安装OpenCV2.4.10 下载地址:http://opencv.org/downloads.html 安装:双击opencv-2.

mingw编译ffmpeg+x265过程记录

mingw编译ffmpeg+x265过程记录 email: [email protected] 工作环境 OS:windows 7 1.相关资源下载 Ffmpeg-2.3     http://ffmpeg.org/releases/ffmpeg-2.3.3.tar.bz2 X265-1.3下载  https://bitbucket.org/multicoreware/x265/wiki/Home http://ffmpeg.zeranoe.com/builds/source/external_

ubuntu 14.04 opencv2.4.13 安装

1.下载然后解压安装压缩包 unzip opencv-2.4.13.zip 2. 进入刚解压的文件夹,建立release文件夹 cd opencv-2.4.13 mkdir release 3. 安装一下必须的依赖库 sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev sud

Linux+java+opencv2.4.13+tomcat部署

花了n多小时终于将opencv编译完,生成的so动态库和jar文件,并将项目用tomcat 部署上了.对于我这个菜鸟来说真心不容易. 之前在windows里用opencv2.4.13.exe 安装完自动生产opencv_java2413.dll 和opencv_java.jar.但是项目要部署到Linux上这个就不行了.结果网上也找不到对应的opencv_java.so可以下下载.结果只能自己编译,现下载虚拟机里安装的ubuntu系统.并在里面把所需要的开发环境搭建好. 参考资料:http://

ubuntu14.04中安装opencv2.4.13

1. 先下载OpenCV的源码 2. 解压到任意目录 unzip opencv-2.4.13.zip 3. 进入源码目录,创建release目录 cd opencv-2.4.13 mkdir release 4. 可以看到在OpenCV目录下,有个CMakeLists.txt文件,需要事先安装一些软件 sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config python-dev python-numpy libavc

开发人员学Linux(9):CentOS7编译安装Git-2.13.1及使用

1.前言在上一篇讲述了如何在CentOS7上编译安装Subversion1.9.5和Apache2.4.25,并与Apache2.4.25集成,达到多个SVN版本库集中授权控制的效果.在传统的企业里面使用SVN来作为源代码版本工具的比例是比较高的,但在一些互联网企业里面很多已经在使用git来作为源代码版本管理工具了.网上关于SVN和Git的比较说明是很多的,其中最重要一个区别就是SVN是集中式的,git是分布式的,比如要查看版本库的历史提交记录,在SVN中必须要在能够连接到SVN服务器才可以,而

APK反编译jd-gui代码分析(草稿记录)

1. 连续for循环 反编译代码: 1 private void removeHideLines() 2 { 3 int i = 0; 4 if (i >= this.lines.size()) {} 5 for (int j = 0;; j++) 6 { 7 if (j >= this.recordLines.size()) 8 { 9 return; 10 if (((MusicTrackLine)this.lines.get(i)).getX() + ((MusicTrackLine)t

Clion使用MinGW编译好的boost库

MinGW编译Boost库可以参考我之前写的编译Boost的文章. 以下是cmake链接boost静态库的配置: 1 cmake_minimum_required(VERSION 3.8) 2 3 project(clions) 4 5 set(CMAKE_CXX_STANDARD 14) 6 set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/Install CACHE PATH "Install here" FORCE) 7 8

使用MinGW编译Qt Creator

Qt Creator中编译项目使用的是MinGW/g++编译器,而Qt提供的Qt Creator本身是由MSVC2013编译的,二者的build key不同,故而Qt Creator中编译的插件无法在Qt Creator中使用(这个搭配真的是滑天下之大稽呀).为了在Qt Creator中使用自定义插件,有两种方法,一种是也使用MSVC编译器编译插件,另一种就是使用MinGW重新编译Qt Creator.以下记录下使用MinGW编译器编译Qt Creator的过程,插件的制作可参考Qt Creat