build opencv by mingw & cmake on windows

来源:互联网 发布:unity3d金属材质下载 编辑:程序博客网 时间:2024/05/12 01:56

[from]

1.) Installed Code::Blocks with the (MinGW) C++ compiler option. This should among other install the C++ compilers and mingw32-make to "C:\Program Files\CodeBlocks\MinGW\bin" (I tried to install the latest MinGW using "mingw-get install gcc g++ mingw32-make" from www.mingw.org but I got an error in extracting some files…)

2.) Added "C:\Program Files\CodeBlocks\MinGW\bin" to system PATH (at your own judgment: remove any other paths to mingw (Somehow devcpp MinGW paths with different versions? messed up the build process))
3.) Installed Cmake 2.8
4.) Extracted "OpenCV-2.2.0-win.zip" to "C:\OpenCV-2.2.0-win" (It creates a second folder so the final destination looks like that: (C:\OpenCV-2.2.0-win\OpenCV-2.2.0")
5.) Ran Cmake (cmake-gui)
6.) Set the source code: C:\OpenCV-2.2.0-win\OpenCV-2.2.0
7.) Set where to build the binaries: e.g. C:\OpenCV2.2MinGW
8.) Pressed Configure
9.) Let Cmake create the new folder
10.) Specified the generator…: MinGW Makefiles
11.) Selected "Specify native compilers" and clicked next
12.) For C set: C:/Program Files/CodeBlocks/MinGW/bin/gcc.exe
13.) For C++ set: C:/Program Files (x86)/CodeBlocks/MinGW/bin/g++.exe
14.) Clicked finish
15.) In the configuration screen typed in "RELEASE" for "CMAKE_BUILD_TYPE" and selected BUILD_EXAMPLES (I didn't change anything else here like "WITH_TBB" or "WITH QT" etc. I'll try that when I need it)
16.) Clicked Configure again
17.) Clicked Generate
18.) Closed Cmake
19.) Went to the command prompt and inside the folder "C:\OpenCV2.2MinGW" typed "mingw32-make" and hit enter (takes some time)
20.) Then typed "mingw32-make install" and hit enter again
21.) Opened Code::Blocks, created a new project (Configuration similar to http://opencv.willowgarage.com/wiki/CodeBlocks)
22.) In menu: "Project/Build options/Linker settings/Link libraries" added "C:\OpenCV2.2MinGW\lib\libopencv_calib3d220.dll.a" and all the *.dll.a files besides the *dephelp.a files
23.) In menu: "Project/Build options/Search directories/Compiler" added "C:\OpenCV2.2MinGW\include"
24.) In menu: "Project/Build options/Search directories/Compiler" added "C:\OpenCV2.2MinGW\lib"
25.) (If necessary) In menu: Settings/Compiler an Debugger/Toolchain executables" specified C:\Program Files\CodeBlocks\MinGW for the compiler's installation directory.
26.) Opened a sample file (or import into project or copy and paste) e.g. "C:\OpenCV2.2DEVCPP\samples\cpp\dft.cpp" and built it
27.) Added "C:\OpenCV2.2MinGW\bin" to the system path
28.) Ran the program