How to setup OpenCV 2.2 in Codeblocks


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.
Code Blocks                  OpenCV 2.2

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. 

18 comments:

Unknown said...

when I tried to build a file I had the following problem: undefined reference to 'WinMain@16'
Do you know how can I fix it?

Unknown said...

I have give it a try and it worked perfectly for me :)
open source development

Adithya said...

@ab89xyzlucas Actly it Depends on the code ur compiling.. So cant say anything without that..

sanath said...

Sir ; I tried from example/square.c.
so it is work well. When I wait more time (5 min) ,it will give runtime error.
why........?

please help.............

Adithya said...

@sanath Probably the program is flooding some of ur system's memory..
Why do u want to wait for 5mins anyways ;)

HarisH said...

I'm getting the error mentioned below.
"'cvNameWindow' was not declared in this scope".
Can some please help

FRAD said...

hello, I have a problem when try compile my program with opencv library, is this
undefined reference to `cv::FileStorage::FileStorage(std::string const&, int)
and more but this is the first
please help me friend

samir said...

Hi,

Does your procedure is relevant for 64 bit environment user?

On sourceforge, we can download OpenCV-2.2.0-win32-vs2010.exe with pre-compiled 32-bit binaries
and it does not contain 64-bit binaries.

Thanks,


Samir

Adithya said...

Ya it works fine with 64bit environment..

Unknown said...

Hi,
How to install opencv 2.4.1 on codeblocks?

Unknown said...

Yeah. I'd love a walk through for setting up code blocks and OpenCV 2.4.1.

I think I got it to work, but I always get libgcc_s_dw2-1.dll missing errors at run time.

Anonymous said...

Hi..
What do you mean by setting environment variable PATH when installing opencv ?

Thanks

Arthur Arnold said...

Its true; every time a new version of OpenCv is released. The content changes. In V2.4.2 the installation process does not add folders to the PATH variable. The OpenCV Wiki for CodeBlocks is no longer valid. Lastely, the libraries that come with the OpenCV package are for Visual Studio only, and must be rebuilt for the (IDE, I guess). Its not clear how to do this.

cisneha said...

yes it work fine i tried it . Really it is working.



Mobile app development .

lukejamie07 said...

Yes it is working very well.Thank you for sharing this post.

NEMT scheduling software

Benedict Tadman said...

Hello Adithya, thanks for sharing useful information.

Custom Software Development

Web Solution Winner USA said...

Yes it is working very well.Thank you for sharing this post.

Search Engine Optimization said...

Thank you for sharing Social Book marketing website list. Freelance To India also providing Social Media Marketing services.

Post a Comment