ubuntu 12.04でopenCV 2.4.2をコンパイルしてインストールしました。その下/usr/local/include
に、ディレクトリ/usr/local/opencv
と/usr/local/opencv2
.
ここに私が書いたコードがあります:
#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\n";
return -1;
}
namedWindow("Display Image",CV_WINDOW_AUTOSIZE);
imshow("Display Image",image);
waitKey(0);
return 0;
}
このコマンドラインを使用してコンパイルしました:
g++ DisplayImage.cpp -o DisplayImage `pkg-config opencv --cflags --libs`
コンパイル時のエラーはありませんでしたが、結果のバイナリを実行しようとすると/DisplayImage code.png
、次のエラー メッセージが表示されます。
./DisplayImage: error while loading shared libraries: libopencv_core.so.2.4: cannot open shared object file: No such file or directory