Skip to content

Instantly share code, notes, and snippets.

@nucliweb
Last active March 4, 2025 11:32
Show Gist options
  • Save nucliweb/b2a234c673221af5ec24508da7d8b854 to your computer and use it in GitHub Desktop.
Save nucliweb/b2a234c673221af5ec24508da7d8b854 to your computer and use it in GitHub Desktop.
OpenCV C++ Mac M1 Installation Steps

📺 OpenCV C++ Mac M1 Installation Tutorial Video

Commands you need

We need homebrew installed in our system

brew install cmake

mkdir Open_CV && cd Open_CV

git clone https://github.com/opencv/opencv.git

mkdir build && cd build

cmake ../opencv/ .

arch -arm64 cmake ../opencv/ -DWITH_QT=OFF -DWITH_OPENGL=OFF -DFORCE_VTK=OFF -DWITH_TBB=OFF -DWITH_GDAL=OFF -DWITH_XINE=OFF -DBUILD_EXAMPLES=OFF -DBUILD_ZLIB=OFF -DBUILD_TESTS=OFF .

arch -arm64 sudo make -j 4

arch -arm64 sudo make install
@thewoz
Copy link

thewoz commented May 31, 2024

yes a pull was made a few days ago that fixes your error.
I don't know how brew works and how often they update the code.
What you should do is download and install OpenCV by hand.
To do that it seems to me that the script here (and the small changes suggested) should be fine.

@jatinkushwaha14
Copy link

How to build opencv on mac metal gpu to enable metal performance shaders?

@Gary0302
Copy link

When I run 'arch -arm64 cmake ....' I get the error:

arch: posix_spawnp: cmake: Bad CPU type in executable

How do I install a version of make that has the arm64 architecture?

file which cmake show:

/usr/local/bin/cmake: Mach-O 64-bit executable x86_64

Where as file which make shows:

/usr/bin/make (for architecture x86_64): Mach-O 64-bit executable x86_64 /usr/bin/make (for architecture arm64e): Mach-O 64-bit executable arm64e

Hello, I dont know if you have already solve this problem or not, but the way I solve is by reinstall homebrew and make sure you are installing the arm version instead of X86

@kowyo
Copy link

kowyo commented Nov 14, 2024

Hello, I dont know if you have already solve this problem or not, but the way I solve is by reinstall homebrew and make sure you are installing the arm version instead of X86

Hello, I solved it by building the source code instead of using brew at that time. Thank you for your reminder, which I believe will help others.

@chriskery
Copy link

Hello, I dont know if you have already solve this problem or not, but the way I solve is by reinstall homebrew and make sure you are installing the arm version instead of X86

same problem and resolved by reinstall homebrew

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment