To use OpenCV with CodeBlocks, you need to tell CodeBlocks:
- The directory which contains the OpenCV header files →
c:opencvuildinclude
- List of OpenCV libraries needed for linking →
c:opencvuildx86mingwlibslibopencv_*.dll.a
1. Add the OpenCV header files directory
Open Settings → Compiler and debugger... → Search directories tab → Compiler tab
![CodeBlock settings: search directory](https://i.stack.imgur.com/CdQGQ.png)
Click add button for adding a new entry. In the popup dialog, type c:opencvuildinclude
,
![Add OpenCV include directory to CodeBlocks](https://i.stack.imgur.com/LJT7j.png)
and click Ok.
2. Add the OpenCV libraries needed for linking
Open Settings → Compiler and debugger... → Linker settings tab.
![CodeBlocks linker settings](https://i.stack.imgur.com/qrS6W.png)
Click add for adding new entries and open a popup dialog.
![CodeBlock settings: Add libraries to link](https://i.stack.imgur.com/zRFk8.png)
Click the "..." button to open the File Open Dialog. Go to c:opencvuildx86mingwlib
directory and select all files by pressing Ctrl-A.
![enter image description here](https://i.stack.imgur.com/DTIOG.png)
Click Open to add the files,
![enter image description here](https://i.stack.imgur.com/xPVrO.png)
Click Ok to save all settings.
Now that you've set the include directory and the libraries for linking, you can compile
and run your project by pressing F9 key.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…