Program cannot run OpenCV even though others can
Solution 1
On my Ubuntu 11.04, the headers are in: */usr/include/opencv-2.3.1/*
, I assume it should be */usr/include/opencv-2.4.0/*
for you.
You have two solutions:
- When you compile, use the
-I
option:g++ -o [name] [src] -I/usr/include/opencv-2.4.0
- Create symbolic links to opencv-2.4.0/opencv and opencv-2.4.0/opencv2 in /usr/include.
The second solution is useful if you're using CMake, because FindOpenCV2 does not look for OpenCV in /usr/include/opencv-2.4.0
. I hope this (ugly) hack will solve your problem.
Solution 2
Change from:
#include <opencv/cv.h>
to:
#include <opencv2/opencv.hpp>
clifgray
PhD Student at Duke in Marine Science focused on satellite and drone based remote sensing for understanding the spatial and temporal variability of ocean biology and ecology. This includes lots of scientific computing, machine learning approaches to remote sensing analysis, and geospatial analysis. Good overview of general techniques here: https://github.com/patrickcgray/open-geo-tutorial Broad background in computer science and space systems. Lots of Python thrown in there.
Updated on June 15, 2022Comments
-
clifgray almost 2 years
I am trying to run a program that uses OpenCV and I have gotten it to run on other machines, and other programs on my machine run using it, but this one returns:
programname.cpp: fatal error: opencv/cv.h: No such file or directory
Anyone know how to fix the path or what might be going wrong? I am running Ubuntu 12.04 and OpenCV-2.4.0