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 🙂

7 thoughts on “Configure CodeBlocks to compile OpenCV codes

  1. Hey pratyush,
    Nice summary there! However, I’m still struggling with getting OpenCV to work, using your handy tips. I’m getting the error “cannot find -lopencv_core”. Somehow it’s not recognizing my linker options…Any idea why?


  2. By the way, I’m using Windows, not Linux/Unix 😛 so, not surprising that there will be problems…

  3. Hi,
    am not sure if the windows build uses -lopencv_core.. try browsing to your installation path (say C:\OpenCV2.3). browse to lib\ directory.. For OpenCV2.1 , i remember the files used to be cv210.lib, cxcore210.lib and highgui210.lib.. just check if similar files are there in the lib folder and pass them into the linker option..

  4. Pingback: codeblocks on linux with opencv « Jaysin's Blog

  5. Pingback: getting codeblocks to work with opencv on linux « Jaysin's Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s