I have gone through so much pain trying to get CodeBlocks being able to properly use the OpenCV libraries on my system so I decided to write a little something about it.
I have Ubuntu 12.04 LTS with CodeBlocks 12.11 (latest stable) and OpenCV 2.4.3 libraries. Follow these steps to setup CodeBlocks IDE to use OpenCV 2.4.3.
Make sure that you have OpenCV installed on your system. There is an excellent guide to follow here that will walk you through the process. You can test your installation by following this guide here.
You can find out where OpenCV and its libraries are installed on your system by using these commands in bash: