MinGW is a collection of freely available and freely distributable Windows specific header files and import libraries, augmenting the GNU Compiler Collection, (GCC), and its associated tools, (GNU binutils). MinGW provides a complete Open Source programming tool set which is suitable for the development of native Windows programs that do not depend on any 3rd-party C runtime DLLs.
Compile OpenCV under MinGW.
MinGW can be used on its own but it is also the "favorite" compiler of the following IDE's:
Code::Blocks RECOMMENDED! (Windows, Linux & Mac)
Eclipse/CDT (Windows, Linux & Mac, but the Wiki page is only for Linux)
DevCpp (Windows)
Tp use MinGW, it is recommended to follow the steps in the CodeBlocks page. But to use MinGW by itself, you can also try these older methods:
OpenCV 2.0 and 2.1
Release package
OpenCV 2.0 and 2.1 are distributed as a package fromsourceforge
Note: This package is only in Release mode (if you want to have the Debug configuration you need to compile it)
Compilation
With its new c++ interface OpenCV needs GCC 4.x (Since version 1.1.0).
You need to download and install MinGW:
Therefore you need to use the official release of MinGW with GCC 4.4.x (released in June 22, 2009 see MinGW GCC 4.4 release note).
Also, there is an unofficial release which use GCC 4.x called MinGW TDM
Once the installation is done, you can look at the InstallGuide to continue the compilation.
After compilation you need to be sure that you link with the generatedlibcv*.a(static version of shared library), and that yourlibcv*.dllare in thePATH.
Note: You can have in the same folder the *.dll for MinGW, MSVC and OpenCV 1.0.0. However you need to be sure to not mix them during the linking.
Tips
TBB library with MinGW
Since version 2.1, OpenCV use the TBB library to support parallel processing:
To build OpenCV with TBB under MinGW. You should compiled TBB sources with the following command:
make compiler=gcc arch=ia32 runtime=mingw tbb
Then you should set :
- TBB_INCLUDE_DIR to "include" subfolder in your tbb source folder
- TBB_LIB_DIR to "build\windows_ia32_gcc_mingw_release" subfolder.
Known Bug specific to MinGW
Building on Windows using MinGW 3.4.5
(Perhaps this is not relevant for OpenCV 2.1)
If you get compile errors to do with __exchange_and_add it is due to the wrong definition of CV_XADD. It can be fixed by:
Open cxoperations.hpp (found in <Open CV base dir>\include\opencv)
- Find this section (lines 67-68 in 2.0):
#else #include <bits/atomicity.h> #if __GNUC__ >= 4 And update it to reference a new definition, __MINGW32__ (defined by the MinGW compiler, see http://predef.sourceforge.net/precomp.html#sec31):
#else #include <bits/atomicity.h> #if __GNUC__ >= 4 || __MINGW32__
OpenCV 1.0
First, you need to download the official release of MinGW at sourceforge.net
You can use directly the win32 binary package (*.dll and *.lib) because C code compile under Microsoft Visual Studio is compatible with MinGW.
However, the VideoSurveillance part can not be used as it include c++ code.