Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Configure OpenCV+QT on Mac

Shulou Source: shulou.com Published: 2022-06-03 04:51:05 11月25日 Update

1. Install Xcodefrom App Store2. Install MacPorts (https://www.macports.org/install.php)

Pay attention to the system version, because the wrong version was installed before, and the reinstallation also caused the following problems

Question: Waiting for other installations to finish (reference: http://superuser.com/questions/169908/installer-hangs-on-waiting-for-other-installations-to-finish-despite-no-other)

Solution: 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

Remember to update, it's a little slow. (https://trac.macports.org/ticket/43228):

Terminal: sudo port selfupdate

3. Install CMake (http://www.cmake.org/download/)

It has been installed before but failed. It is said that it cannot be run without verification, but there is still this problem after reinstallation. Adjust the security permissions of mac:

(reference: 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./)

It is found that the cmake instruction is still not recognized in Terminal, and it is not possible to modify the path and export path (http://blog.csdn.net/ikscher/article/details/8348925),

Brew (http://stackoverflow.com/questions/20381128/how-to-install-homebrew-on-mac-osx):) is installed.

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

Then install CMake (https://github.com/travis-ci/travis-ci/issues/2175)) with brew

Terminal:

Brew update

Brew install cmake

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

Pay attention to the version and decompress it.

Terminal:

Sudo port uninstall opencvcd opencv directory mkdir buildcd buildcmake-G "Unix Makefiles".. make-j8sudo make install

Compile static library (http://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/)1) Open CMake, select the opencv source code path and static inventory path 2) Click to configure, remove BUILD_SHARED_LIBS, BUILD_TESTS, WITH_1394, WITH_FFMPEG, add x86 libraries 64 to CMAKE_OSX_ARCHITECTURES, and add sdk to CMAKE_OSX_SYSROOT "/ Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" 3) reconfigure and generate 4) Terminal:cd static library directory make (This will take awhile) sudo make install

5. Set up developer activity directory

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

6. Use in Qt

Once Qt is installed, add libraries to Qt Creator as needed, then INCLUDEPATH + = / usr/local/includeDEPENDPATH + = / usr/local/includemacx: PRE_TARGETDEPS + = / usr/local/lib/libopencv*.amacx: LIBS + =-L / usr/local/lib/libopencv* open a console test program to test it, remember to add it if necessary

QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9 to pro or

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

Original reference: 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/

Tags: Version directory path problem static reference configuration test no security necessary original text developer instruction console permissions source code program system yes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Microsoft macOS Redmi OPPO Reno