http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.6.1/opencv-2.4.6.1.tar.gz/download
Unzip the OpenCV 2.4.6 source to: D:\opencv246build\
Create a new folder D:\opencv246build\build-gcc482, this will hold the build objs, libs, binaries.
As we need to build this library, so only source is enough.
i686-4.8.2-release-posix-dwarf-rt_v3-rev0 - http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.8.2/threads-posix/dwarf/i686-4.8.2-release-posix-dwarf-rt_v3-rev0.7z/download
In my build, the source code location is: D:\opencv246build
the build target location is: D:\opencv246build\build-gcc482
I use the Build type: Debug
So, the generated dll files will have debug information, you can step into its source code:
mingw32-make
mingw32-make install
Now, all the installed files was in
D:\opencv246build\build-gcc482\install
So, you have:
D:\opencv246build\build-gcc482\install\bin to contain all the dlls
D:\opencv246build\build-gcc482\install\include to contain all the header files
D:\opencv246build\build-gcc482\install\lib to contain all the libraries
When building, I have see a build error reporting like:
The linker can't find libvfw32.a when building highgui.
I checked the MinGW-Builds, and see one library named:
D:\mingw-builds\i686-4.8.2-release-posix-dwarf-rt_v3-rev0\mingw32\i686-w64-mingw32\lib\libmsvfw32.a
To solve this build error, you can just make a copy of libmsvfw32.a, and rename to libvfw32.a, then run mingw32-make again.
This is the configure options I use to build the Opencv library
Detected version of GNU GCC: 48 (408)
Performing Test HAVE_CXX_FNO_OMIT_FRAME_POINTER
Performing Test HAVE_CXX_FNO_OMIT_FRAME_POINTER - Success
Performing Test HAVE_C_FNO_OMIT_FRAME_POINTER
Performing Test HAVE_C_FNO_OMIT_FRAME_POINTER - Success
Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
General configuration for OpenCV 2.4.6 =====================================
Version control: unknown
Platform:
Host: Windows 5.1 x86
CMake: 2.8.11.2
CMake generator: MinGW Makefiles
CMake build tool: D:/mingw-builds/i686-4.8.2-release-posix-dwarf-rt_v3-rev0/mingw32/bin/mingw32-make.exe
Configuration: Debug
C/C++:
Built as dynamic libs?: YES
C++ Compiler: D:/mingw-builds/i686-4.8.2-release-posix-dwarf-rt_v3-rev0/mingw32/bin/i686-w64-mingw32-g++.exe (ver 4.8.2)
C++ flags (Release): -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -march=i686 -fno-omit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -O2 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -march=i686 -fno-omit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3
C Compiler: D:/mingw-builds/i686-4.8.2-release-posix-dwarf-rt_v3-rev0/mingw32/bin/i686-w64-mingw32-gcc.exe
C flags (Release): -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -march=i686 -fno-omit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -O2 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -march=i686 -fno-omit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3
Linker flags (Release):
Linker flags (Debug):
Precompiled headers: YES
OpenCV modules:
To be built: core imgproc flann highgui features2d calib3d ml video objdetect contrib legacy nonfree photo stitching superres ts videostab
Disabled: gpu world
Disabled by dependency: -
Unavailable: androidcamera java ocl python
GUI:
QT: NO
Win32 UI: YES
OpenGL support: NO
Media I/O:
ZLib: build (ver 1.2.7)
JPEG: build (ver 62)
PNG: build (ver 1.5.12)
TIFF: build (ver 42 - 4.0.2)
JPEG 2000: NO
OpenEXR: NO
Video I/O:
Video for Windows: NO
DC1394 1.x: NO
DC1394 2.x: NO
FFMPEG: YES (prebuilt binaries)
codec: YES (ver 53.61.100)
format: YES (ver 53.32.100)
util: YES (ver 51.35.100)
swscale: YES (ver 2.1.100)
gentoo-style: YES
OpenNI: NO
OpenNI PrimeSensor Modules: NO
PvAPI: NO
GigEVisionSDK: NO
DirectShow: YES
Media Foundation: NO
XIMEA: NO
Other third-party libraries:
Use IPP: NO
Use Eigen: NO
Use TBB: NO
Use OpenMP: NO
Use GCD NO
Use Concurrency NO
Use C=: NO
Use Cuda: NO
Use OpenCL: NO
Python:
Interpreter: E:/code/Python27/python.exe (ver 2.7.5)
Java:
ant: NO
JNI: NO
Java tests: NO
Tests and samples:
Tests: NO
Performance tests: NO
C/C++ Examples: NO
Install path: D:/opencv246build/build-gcc482/install
cvconfig.h is in: D:/opencv246build/build-gcc482
-----------------------------------------------------------------
Configuring done
Generating done
That's all, happy debugging!