Problem solved!
I inevitably have to compile OpenCV 2.1 myself using MinGW to get it working.
I found another thread, not here, that redirected me to download TDM-GCC (
http://tdm-gcc.tdragon.net/download), and abandoned the original MinGW. The reason is OpenCV 2.1 needs GCC 4.4.0 and above. The original MinGW comes with GCC 3.8.x. This can compile only up to maybe 40% of the framework and gives out errors.
So, what I did was:
1. Download and install CMake 2.8
2. Download and install MinGW by TDM.
3. Set a PATH to TDM MinGW's bin folder, if it is not set.
4. Generate the Makefiles needed using CMake by choosing MinGW option when asked.
5. Launch cmd, go to OpenCV's directory and type "mingw-make" or "mingw32-make".
After step 5, the DLLs will be placed in the bin/ folder and the *.dll.a files will be placed in the lib/ folder.
6. Update my PRO file with:
LIBS += "C:\OpenCV2.1\lib\libcv210.dll.a" \
"C:\OpenCV2.1\lib\libcvaux210.dll.a" \
"C:\OpenCV2.1\lib\libcxcore210.dll.a" \
"C:\OpenCV2.1\lib\libhighgui210.dll.a"
LIBS += "C:\OpenCV2.1\lib\libcv210.dll.a" \
"C:\OpenCV2.1\lib\libcvaux210.dll.a" \
"C:\OpenCV2.1\lib\libcxcore210.dll.a" \
"C:\OpenCV2.1\lib\libhighgui210.dll.a"
To copy to clipboard, switch view to plain text mode
7. Build my OpenCV code and done. The build should work.
8. Copy the DLL files from the OpenCV2.1/bin folder to the debug/ or release/ folders, depends on the build mode, and run the code.
The copying is needed because I did not set a PATH to OpenCV and I plan to distribute my Qt apps with the DLLs. If you think this is troublesome, you will need to set a path to those DLLs.
9. You are done!
NOTE: As of this writing, somehow the methods found in highgui module is bugged. I cannot get it to display a window properly. However, I think this is not a too big of an issue as I can always display images as QImage, and I found a lot of tutorials and forum threads on how to do this in Qt. Hopefully the OpenCV developers fix the problem.
Bookmarks