The thing with OpenCV libraries is that the method to set it up with codeblocks is different for every newer version! The last tutorial I posted was for Setting up OpenCV 2.0 with codeblocks. In this post I would follow the similar method and try to be as clear as possible.
I will be using codeblocks 10.05 and OpenCV 2.2 on Windows 7 operating system. MinGW compiler ( The GNU GCC compiler ) in the codeblocks. So first check if your code blocks has this compiler installed. If no, then download one from the link below.
Download the latest version of codeblocks and OpenCV from the below links.
Follow the normal installation for code blocks. I couple of things to note during OpenCV installation is that it should be installed in the C:\ and the environment variable PATH should be set. You would be prompted during the installation.
Let me start with the method..
1) Open Code blocks and goto menu Settings > Compiler and Debugger. Click on the the Linker Setting tab and add all the libraries from C:\OpenCV2.2\lib\ directory. Actually you would require only some, but just in case if your program requires.
You can see in the screenshot, all the libraries are added. One more thing to note, the compiler selection at the top. It should be set to GNU GCC compiler.
2) Click on the Search directory > Compiler Tab. Add C:\OpenCV2.2\include and C:\OpenCV2.2\include\opencv.
3) Next goto the adjacent Linker tab and add C:\OpenCV2.2\lib.
I think that should do! You might also wanna check the Toolchain executables Tab. Many people encounter problem with this. If the directories are not set accordingly. You just need to browse the compiler directory. See the screenshot to get it right.
Testing a sample program delaunay.c. Output screenshot shown.
You can also check my post "OpenCV Tutorial References" where i have listed out some important links which could help you in understanding OpenCV better. Also check other posts on OpenCV.
Post a comment in case you have any problem getting opencv 2.2 work on your code blocks. Post the error, Il try best to get a solution.