As soon as you click download button on mingw website The following page will open in your browser (from the SourceForge.net web site). The following exe file will be downloaded with the name mingw-get-setup.exe.
Unfortunately OpenCV doesn’t come with prebuilt mingw/TDM (64 bit) binaries for windows.In this tutorial, we are going to build them ourselves.
Environment setup
Codeblocks Mingw 64 Bit Download
- Download the source of OpenCV 3.2. Create the following folders:
64-bit
- C:opencvsource
- C:opencvbuild
- Extract the zipped opencv to C:opencvsource.
- Download codeblocks without mingw. Because the default MinGW comes with codeblocks is 32 bit.
- Download TDM 64 bit version. Install it in C: drive. it will look like C:TDM-GCC-64. The bin folder should be registered automatically in system path during the installation process, if not then using any path editor software you can do it manually. Set C:TDM-GCC-64bin folder in the system variable.Alternatively, you can use mingw 64bit
- Download and install Cmake from here. Again the bin folder of cmake installation directory should be set in system path automatically, if not do it manually.
Making binaries
- Open cmake, set source path to C:opencvsource and binary path to C:opencvbuild.
- Hit configure button and from the drop-down menu select ‘codeblocks – MinGW Makefiles’ and press finish. When done uncheck all python stuff ( as it didn’t work on my pc). Now hit generate button.
- you will find a codeblocks project file (opencv.cbp) in C:opencvbuild folder. Just double click it and codeblocks will load it.
- Go to ‘settings‘, choose ‘compiler’ and click ‘Toolchain executable‘. In the ‘compiler’s installation directory‘ field choose the “bin” folder of MinGW C:TDM-GCC-64bin.set the following:
- c compile: gcc.exe
- c++ compiler: g++.exe
- Linker for dynamic libs: ar.exe
- Finally, from codeblocks, you just need to build it. build target should be set to ‘install’ so that you can find all the binaries inside the ‘install’ folder of C:opencvbuildinstall.Just go to ‘build ->select target -> install’ in the codeblocks menu and then hit ‘build->build’ button.Go get some tea :) Its gonna take some time (2-3 hour depending on the configuration of your pc).
- After that set the path C:opencvbuildinstallx64mingwbin using path editor.
Mingw 64 Bit Download
Running test program
- Create a C++ project ‘Test’ in codeblocks.
- Go to settings -> compiler. Select ‘search directories’ and in the ‘compiler’ tab chose the followings:
- C:opencvbuildinstallinclude
- C:opencvbuildinstallincludeopencv
- C:opencvbuildinstallincludeopencv2
- Select ‘Linker’ tab and add C:opencvbuildinstallx64mingwlib
- Under ‘Linker Settings’ tab add required libraries C:OpenCVmy_buildinstallx64mingwlib*.dll.a
code
Enjoy!