I compiled and installed openCV 2.4.2 in ubuntu 12.04. Under /usr/local/include
I can see the directories /usr/local/opencv
and /usr/local/opencv2
.
Here is the code I wrote:
#include <cv.h>
#include <highgui.h>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc,char **argv)
{
Mat image;
image = imread(argv[1],1);
if(argc != 2 || !image.data)
{
cout << "No image data
";
return -1;
}
namedWindow("Display Image",CV_WINDOW_AUTOSIZE);
imshow("Display Image",image);
waitKey(0);
return 0;
}
I compiled it using this command line:
g++ DisplayImage.cpp -o DisplayImage `pkg-config opencv --cflags --libs`
There were no compile time errors, however when I try to run the resulting binary with /DisplayImage code.png
I get the following error message:
./DisplayImage: error while loading shared libraries: libopencv_core.so.2.4: cannot open shared object file: No such file or directory
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…