在Mac上配置OpenCV+QT

发布时间:2020-07-15 17:10:32 作者:麻雀音符
来源:网络 阅读:1158

1.安装Xcode

    from App Store

2.安装MacPorts(https://www.macports.org/install.php)

    注意系统版本,因为之前装错了版本,重装还导致了下面的问题

    问题:Waiting for other installations to finish(参考:http://superuser.com/questions/169908/installer-hangs-on-waiting-for-other-installations-to-finish-despite-no-other)
    解决:Chances are that a previous installation hung and the lock was never cleaned up.
       1)sudo rm /private/var/db/mds/system/mds.install.lock
       2)  reboot
    记得更新下,有点慢。(https://trac.macports.org/ticket/43228):

    Terminal: sudo port selfupdate


3.安装CMake

  (http://www.cmake.org/download/)

之前有安装过但是失败了,说是没验证不能运行,重新安装了下还是有这个问题,调整了下mac的安全权限:

  (参考:http://www.native-instruments.com/en/support/knowledge-base/show/949/mac-os-10.8-error-message-...-cant-be-opened-because-it-is-from-an-unidentified-developer./)

发现Terminal里还是不是识别cmake指令,修改路径并export path 也不行(http://blog.csdn.net/ikscher/article/details/8348925),

就装了brew(http://stackoverflow.com/questions/20381128/how-to-install-homebrew-on-mac-osx):

Terminal:ruby-e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

然后用brew安装了CMake(https://github.com/travis-ci/travis-ci/issues/2175)

Terminal: 

brew update

brew install cmake

4.安装OpenCV(http://opencv.org/downloads.html)

注意下版本,解压。

Terminal:

sudo port uninstall opencvcd opencv的目录mkdir buildcd buildcmake -G "Unix Makefiles" ..make -j8sudo make install

编译静态库(http://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/)1)打开CMake,选好opencv源码路径和静态库存放路径2)点击进行配置,去掉BUILD_SHARED_LIBS、BUILD_TESTS、WITH_1394、WITH_FFMPEG,添加x86_64到CMAKE_OSX_ARCHITECTURES,添加sdk到      CMAKE_OSX_SYSROOT,“/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk”3)重新配置并生成4)Terminal:cd 静态库目录make (This will take awhile)sudo make install

5.设置开发者活动目录

Teriminal:sudo /usr/bin/xcode-select –switch /Applications/Xcode.app/Contents/Developer

6.在Qt中使用

安装好Qt在Qt Creator中根据需要添加库,即可INCLUDEPATH += /usr/local/includeDEPENDPATH += /usr/local/includemacx: PRE_TARGETDEPS += /usr/local/lib/libopencv*.amacx: LIBS += -L /usr/local/lib/libopencv*开一个控制台测试程序测试之,必要时记得加

QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9 到pro里
或者


http://stackoverflow.com/questions/14940126/opencv-2-4-3-cant-find-imread-and-surffeaturedetectordetect





原文参考:http://drthitirat.wordpress.com/2014/09/21/install-opencv-2-4-9-and-qt-5-3-2-on-mac-osx-10-9-5-and-xcode-6-0-1/

              

推荐阅读:
  1. 在MAC上搭建Redis环境
  2. 在Mac上安装PHP的方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

system private previous

上一篇:Istio调用链埋点原理剖析—是否真的“零修改”分享实录(下)

下一篇:用cmd运行Spyder的方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》