在Mac上配置OpenCV+QT

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:rubye“$(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/

              

原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/194110.html

(0)
上一篇 2021年11月15日
下一篇 2021年11月15日

相关推荐

发表回复

登录后才能评论