Configure CodeBlock With OpenCV

CONFIGURE CODEBLOCK WITH OPENCV
ref:http://jonniedub.blogspot.co.id/2013/01/setting-up-codeblocks-ide-for-use-with.html?showComment=1454444260714#c506464558721086998
http://blog.csdn.net/mummyding/article/details/49804921
1. Create new project:
File -> New -> Project…-> Find ‘OpenCV Project’ -> click ‘Go’ -> Next -> Write Project Title and the Path ->
Compiler: GNU GCC Compiler -> Finish

2. Default opencv template (main.cpp in /Sources/ directory) is created. Here is main.cpp:

3. Its time to configure this project so it’d be linked to opencv library.
From eclipse configuration above, we get the libraries path by using:
pkg-config –cflags opencv
pkg-config –libs opencv
We’ll do the same here:
a. Right click the Project Name ‘OpenCV’ -> Build Options -> Click the Project name (OpenCV) DO NOT the ‘Debug’ ->
Search directories tab -> Compiler tab -> click Add -> fill with: /usr/local/include/opencv
b. then click Linker tab -> click Add -> fill with: /usr/local/lib
c. Then at Linker settings tab -> In Link Libraries, Add this (one by one):
opencv_core
opencv_imgcodecs
opencv_highgui

In Others linker options:, add:
opencv-config --ldstaticflags

d. click OK

4. Test it!
Right click the Project name ‘OpenCV’ -> Build
make sure everything okay
Then click ‘Run’ (the green arrow) or from Build -> Run
SHORTCUT: F9 (Build and Run at ONCE!)

Leave a Reply

Your email address will not be published. Required fields are marked *