0

Hi I am trying to get opencv to work on my m1 mac.

I am getting this error:

Undefined symbols for architecture arm64:

This is my code:

#include <opencv2/opencv.hpp>

int main(){
    cv::Mat img = cv::imread("hej.jpg");
    return 0;
}

And this is my CMakeLists file:

cmake_minimum_required(VERSION 3.19)
project(test)

set(CMAKE_CXX_STANDARD 14)

set(OpenCV_DIR "/opt/homebrew/Cellar/opencv")

find_package( OpenCV REQUIRED )
include_directories(include ${OpenCV_INCLUDE_DIRS} )
add_executable(test main.cpp)

Would really appriciate some help! I have read people getting OpenCV to work on M1 but dont know how.

tjolahopp
  • 1
  • 1
  • You didn't link with the opencv libraries in your CMakeLists.txt. You should have a `target_link_libraries(test ${OpenCV_LIBS})` – drescherjm Nov 29 '21 at 21:34
  • oh ok thanks! how should I do that? – tjolahopp Nov 29 '21 at 21:35
  • Related: [https://stackoverflow.com/questions/37691912/linking-opencv-in-a-project-using-cmake](https://stackoverflow.com/questions/37691912/linking-opencv-in-a-project-using-cmake) – drescherjm Nov 29 '21 at 21:36

0 Answers0