首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

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

2012-12-21 
请教一个关于ubuntu下openCV程序编译出错的问题源代码#include cv.h#include highgui.h#include iost

请教一个关于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被版主删除


[其他解释]
OK....
[其他解释]

引用:
OK,解决了
请问如何解决的呢?我现在是用jni调用,编译的时候出现这个错误了,不知道如何解决啊
[其他解释]
楼主,我也遇到了同样的问题,求指教

热点排行