V
V
Vladimir Kuts2020-06-10 23:15:05
OpenCV
Vladimir Kuts, 2020-06-10 23:15:05

Trouble installing from source OpenCV on MacOS?

I install on MacOS from the OpenCV sources like this:

cd opencv-4.3.0
mkdir build
cd build
cmake  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ../
make -j7
make install

everything is set - no errors ...

After that I try to compile the example
g++ -std=c++11  -I/usr/local/include/opencv4 -L opencv-4.3.0/build/lib  -L /usr/local/lib/opencv4   example.cpp


Linking ends with an error:
Undefined symbols for architecture x86_64:
  "cv::namedWindow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
      _main in example-4b35ae.o
  "cv::Mat::deallocate()", referenced from:
      cv::Mat::release() in example-4b35ae.o
  "cv::Canny(cv::_InputArray const&, cv::_OutputArray const&, double, double, int, bool)", referenced from:
      _main in example-4b35ae.o
  "cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
      _main in example-4b35ae.o
  "cv::imshow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cv::_InputArray const&)", referenced from:
      _main in example-4b35ae.o
  "cv::waitKey(int)", referenced from:
      _main in example-4b35ae.o
  "cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)", referenced from:
      _main in example-4b35ae.o
  "cv::fastFree(void*)", referenced from:
      cv::Mat::operator=(cv::Mat&&) in example-4b35ae.o
      cv::Mat::~Mat() in example-4b35ae.o
  "cv::Mat::convertTo(cv::_OutputArray const&, int, double, double) const", referenced from:
      _main in example-4b35ae.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


How can this be fixed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2020-06-12
@fox_12

Since there are no answers, I will answer: CMakeLists.txt
works through cmake :

cmake_minimum_required(VERSION 2.8)
project( example )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( example example.cpp )
target_link_libraries( example ${OpenCV_LIBS} )

cmake .
make

and everything worked

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question