Ubuntu14.04LTS下Qt5.3.2和OpenCV2.4.9环境的搭建以及遇到的问题

        最近心血来潮,想学学Linux下的编程,正好以后学习中可能要用到Opencv,而且听说Qt与Opencv的衔接蛮不错的,所以......

    【1】Qt5.3.2的安装:

        首先从官网上下载Qt 5.3.2 for Linux 32-bit ,点此下载

        得到qt-opensource-linux-x86-5.3.2.run文件,我放在了Ubuntu的Downloads文件夹下。

        ① cd Downloads

        ② chmod +x qt-opensource-linux-x86-5.3.2.run

        ③ sudo ./qt-opensource-linux-x86-5.3.2.run

        后面的按照指示操作就是了。不过安装好后,桌面上并没有快捷方式,不过Ubuntu会将自动安装的软件快捷方式保存在/usr/share/applications目录下,如果我们要创建桌面快捷方式,只需要右键、复制,然后粘贴到桌面就好了。


    【2】OpenCV2.4.9的安装:

        我是参考的网上别人安装的教程,网址:点此打开

        不过,在按照这个方法安装后,在用测试小程序测试时,我遇到了一些问题。不过这个方法应该是没问题的,毕竟我看下面的评论,一个个的都是好评。


    【3】遇到的问题

        不过我显然没那么好的命,开始时并没有成功。

        ① 在最初,我参考的是这位网友的测试程序:点击打开链接

        然后运行后,直接弹出了一个黑框,就像windows下的dos界面一样,上面写着: Please press <RETURN>   to close this window...,除此之外,没有任何反应,然后我看下面的输出,那儿写着我的程序 Crashed 了......

       ②  后来,我就参考了另一位网友的测试程序:点击打开链接

        运行时,直接出了error:realloc(): invalid pointer......

        从此,我就艰难的开始了寻找解决办法......最后,终于找到了......

        这是我从谷歌上找到的一个答案,方法如下:

    ① cd opencv-2.4.9
    ② rm -r build
    ③ mkdir build
    ④ cd build
    ⑤ cmake -D WITH_XINE=ON -D WITH_OPENGL=ON -D WITH_TBB=ON -D BUILD_EXAMPLES=ON ..
    ⑥ make -j4
    ⑦ sudo make install
终于,我也得到了第二个测试程序同样的结果,然而,这时,时间已经过去了一天半了...... 大哭

原文网址:点击打开链接

上面说:

I have met the same problem, I search it the whole morning and solve it by re-install the OpenCV. My opencv was the version 2.4.9, and build on the Ubuntu 12.04 system following a post , I installed the QT creator later using the Linux installer. The version of QT creator is 3.1.2 based on the QT 5.3.1. My OpenCV was installed on a customized path. I just deleted the build folder

cd opencv-2.4.9
rm -r build

and I just build the OpenCV again without the -D WITH_QT flag in cmake

mkdir build
cd build
cmake -D WITH_XINE=ON -D WITH_OPENGL=ON -D WITH_TBB=ON -D BUILD_EXAMPLES=ON ..
make -j4
sudo make install
the -j4 flag in the make means that make in 4 cores parallel. and the Magic happens, the code works! the reason why it does not work is that when using the cmake WITH_QT flag the system build the opencv using the system default version of the qt, which is not compatible with the newest version of the qt downloaded from the website. however, to make it work, we must have the right version of the QT .


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值