Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

OpenCV error on cvShowImage not declared

📅 2013-Jul-04 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ error, highgui, opencv ⬩ 📚 Archive

Problem

I tried to compile some code that uses OpenCV and got this error:

foo.cpp:275:25: error: ‘cvShowImage’ was not declared in this scope
foo.cpp:532:29: error: ‘cvSaveImage’ was not declared in this scope
foo.cpp:556:45: error: ‘cvLoadImage’ was not declared in this scope

That is, the compiler is not able to find the declarations of cvShowImage, cvSaveImage and cvLoadImage. This code used to compile without errors in older versions of OpenCV.

Solution

In newer versions of OpenCV, these declarations are in the highgui.h header file and it needs to be explicitly included:

#include <opencv/highgui.h>

Tried with: OpenCV 2.4.9 and Ubuntu 12.04 LTS