codeblocks-13.12mingw 配置opencv-3.1.0(一)
2016-01-17 21:18
459 查看
一、问题描述
由于opencv-3.1.0 只提供编译好的vc12 和vc14版本,而codeblocks默认使用的是mingw编译器并没有提供,所以如果使用vc12或vc14就会出现Build: Debug in test (compiler: GNU GCC Compiler)===|
obj\Debug\main.o||In function `main':|
E:\OpenCv工程\test\main.cpp|5|undefinedreference to `cvLoadImage'|
E:\OpenCv工程\test\main.cpp|6|undefinedreference to `cvNamedWindow'|
E:\OpenCv工程\test\main.cpp|7|undefinedreference to `cvShowImage'|
E:\OpenCv工程\test\main.cpp|8|undefinedreference to `cvWaitKey'|
E:\OpenCv工程\test\main.cpp|9|undefinedreference to `cvReleaseImage'|
E:\OpenCv工程\test\main.cpp|10|undefinedreference to `cvDestroyWindow|
“未定义”错误
测试用例
#include "cv.h" #include "highgui.h" int main() { IplImage* img = cvLoadImage("OL.jpg",1); cvNamedWindow( "Example1", 0 ); cvShowImage("Example1", img); cvWaitKey(0); cvReleaseImage( &img ); cvDestroyWindow( "Example1" ); return 0; }
解决办法就是用codebooks自带的编译器重新编译OpenCV 源码
在这里我们使用cmake工具生产makefile文件
二、cmake 配置
(1)选择本地编译器,以及编译器类型
(2)选择编译器所在路径,其实就是CodeBlocks 中gcc和g++的路径
(3)选择要编译源码路径,已经编译后生存文件存放路径
Where is the source code 选择OpenCV 源码解压地址 D:/OpenCV/opencv/sourcesWhere to build the binaries 编译后文件存放的位置 D:/OpenCV/opencv/buildCodeBlocks
(4)然后Configure
(5)完成进度条,选择Generate
此时makefile文件已经生成三、用mingw32对其进行编译
(1)之后用mingw对其进行编译,进到刚才的保存目录,这里是D:/OpenCV/opencv/buildCodeBlocks”,输入mingw32-make;完成后输入 mingw32-make install
ps:(我的mingw32 路径在D:\ProgramFiles (x86)\CodeBlocks\MinGW\bin 以配置在环境变量中Path中,所以能直接使用mingw32)
(2)运行完毕后便生成了的OpenCV库,进入“D:\OpenCV\opencv\buildCodeBlocks\install”可以查看
下面配置codeblocks 见codeblocks-13.12mingw
配置opencv-3.1.0(二)
相关文章推荐
- docker:网络基础配置
- linux 常用命令
- nginx整合tomcat集群并做session共享----测试案例
- linux vi编辑器
- 运行Tomcat9.0,jdk1.7出现tomcat unsupported major.minor version 52.0
- linux trap命令举例
- 【opencv】显示图像
- NSOperation
- nginx中常见的变量
- 【转】centos7安装
- OpenSceneGraphic 着色器中数组的应用
- linux搭建ntp服务
- nginx同时监听本机ipv4/ipv6端口
- 设置Hadoop+Hbase集群pid文件存储位置
- Project Euler 101 :Optimum polynomial 最优多项式
- 嵌入式Linux研发,非常值得研究的几个开源项目
- Linux(Ubuntu)环境下使用Fiddler
- 博主常用(推荐)网站,持续更新中
- 【Linux】新建用户、用户组以及为新用户分配权限
- 记录参加“牛津计划.Docker在线黑客松”比赛的过程