codeblocks-13.12mingw 配置opencv-3.1.0(一)
一、問題描述
由于opencv-3.1.0 只提供編譯好的vc12 和vc14版本,而codeblocks默認(rèn)使用的是mingw編譯器并沒有提供,所以如果使用vc12或vc14就會(huì)出現(xiàn)
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|
“未定義”錯(cuò)誤
測試用例
#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工具生產(chǎn)makefile文件
二、cmake 配置
(1)選擇本地編譯器,以及編譯器類型
(2)選擇編譯器所在路徑,其實(shí)就是CodeBlocks 中g(shù)cc和g++的路徑
(3)選擇要編譯源碼路徑,已經(jīng)編譯后生存文件存放路徑
Where is the source code 選擇OpenCV 源碼解壓地址 D:/OpenCV/opencv/sources
Where to build the binaries 編譯后文件存放的位置 D:/OpenCV/opencv/buildCodeBlocks
?
(4)然后Configure
(5)完成進(jìn)度條,選擇Generate
此時(shí)makefile文件已經(jīng)生成
三、用mingw32對其進(jìn)行編譯
(1)之后用mingw對其進(jìn)行編譯,進(jìn)到剛才的保存目錄,這里是D:/OpenCV/opencv/buildCodeBlocks”,輸入mingw32-make;
完成后輸入?mingw32-make?install
?ps:(我的mingw32 路徑在D:\ProgramFiles (x86)\CodeBlocks\MinGW\bin 以配置在環(huán)境變量中Path中,所以能直接使用mingw32)
(2)運(yùn)行完畢后便生成了的OpenCV庫,進(jìn)入“D:\OpenCV\opencv\buildCodeBlocks\install”可以查看
下面配置codeblocks 見codeblocks-13.12mingw 配置opencv-3.1.0(二)
總結(jié)
以上是生活随笔為你收集整理的codeblocks-13.12mingw 配置opencv-3.1.0(一)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tuxedo错误码6_TUXEDO错误解
- 下一篇: VUE router 导航重复点击报错的