0

I have some simple opencv files which I wanted to compile on 12.04.

I have installed all the -dev packages

They use:

#include <cv.h>
#include <highgui.h>

at the top of the file.

Using

g++ `pkg-config --cflags --libs opencv` canny.cpp

gives cv.h: No such file or directory

pkg-config seems to list /usr/include/opencv but the directory created at install is /usr/include/opencv2

Is this a bug? Any advice?

1

5 Answers 5

2

Assuming you've installed the libraries right, the command you're using to compile the code through the terminal is wrong. I've tried it myself, and it doesn't work! Try the following,

g++ canny.cpp -o canny `pkg-config --cflags --libs opencv` 

This line should work fine. Please, try it and let us know.

0

You have to install the package libcv-dev in order to get the old-style header files in /usr/include/opencv/.

0

Replace your header files in the code with this (Assuming your path is "/usr/include/"):

#include <opencv2/opencv.hpp>

and use this to compile

g++ canny.cpp -o canny -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect
0

you must include "/usr/local/include/opencv" folder in compile time to work.

0
g++ filename.cpp -o outputfile-name `pkg-config --cflags --libs opencv`

Compilation example:

g++ simple.cpp -o sample `pkg-config --cflags --libs opencv` 

Run:

./sample

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .