Configure CodeBlocks to compile OpenCV codes

CodeBlocks is one of the IDE(s) that i prefer using due to its simplicity and fast interface. Plus the benefit of having MATLAB like command suggestions. The steps are outlined below:

  • Search the path where opencv is installed in your system.. you can do a :

locate cv.h

  • in my system, this returns : /usr/local/include/opencv/cv.h. Copy the path till the opencv directory, i.e : /usr/local/include/opencv/
  • Now, open CodeBlocks > New Project > (any project type of your choice.. for starters, Console Project is a good beginning) . Now goto,

Project > Build Options > Linker Settings tab

  • Under “Other Linker options” add the following, one below the other:


  • Now, in the same window, under “Search directories tab”, add the opencv directory you copied above, i.e. for my system, it’ll be :


  • Now, Project > Properties > C/C++ Parser options, again add the same directory path.

And you are done !! Enjoy compiling OpenCV codes in CodeBlocks 🙂