请问一个关于ubuntu上openCV程序编译出错的有关问题

请教一个关于ubuntu下openCV程序编译出错的问题
源代码

#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;
}



编译安装了openCV,现在在/usr/share/include 目录下有opencv 和opencv2两个文件夹

第一次用g++ DisplayImage.cpp -o DisplayImage  使命编译,提示没有 cv.h 这个文件
然后网上有人说用 g++ `pkg-config opencv --libs --cflags opencv` DisplayImage.cpp -o DisplayImage 命令,但是出现了下面的错误
好像是命名空间的问题,求解决方法。

/tmp/cc1ounoJ.o: In function `main':
DisplayImage.cpp:(.text+0x6c): undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
DisplayImage.cpp:(.text+0x10c): undefined reference to `cv::namedWindow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
DisplayImage.cpp:(.text+0x13a): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
DisplayImage.cpp:(.text+0x16e): undefined reference to `cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
DisplayImage.cpp:(.text+0x190): undefined reference to `cv::waitKey(int)'
/tmp/cc1ounoJ.o: In function `cv::Mat::~Mat()':
DisplayImage.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
/tmp/cc1ounoJ.o: In function `cv::Mat::operator=(cv::Mat const&)':
DisplayImage.cpp:(.text._ZN2cv3MataSERKS0_[cv::Mat::operator=(cv::Mat const&)]+0x111): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
/tmp/cc1ounoJ.o: In function `cv::Mat::release()':
DisplayImage.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x47): undefined reference to `cv::Mat::deallocate()'
collect2: ld 返回 1

------最佳解决方案--------------------
先把openCV依赖的东西装上,比如GTK等等。
------其他解决方案--------------------
OK,解决了
------其他解决方案--------------------
求解决方案。。。
我也不想用windows了。。。
------其他解决方案--------------------
我也是 图像学的。。。  还真不知道opencv支持 linux。。。。
------其他解决方案--------------------
该回复于2012-09-10 09:33:44被版主删除
------其他解决方案--------------------
看错误是没有链接 opencv 的库,自己找找在那里,然后 -l 进来就好了。
------其他解决方案--------------------
该回复于2012-09-10 10:26:57被版主删除