0

I installed opencv by brew, I tried to reinstall for several times and it didn't help. I have googled for a lot of time but didn't find a valid way to solve this.

I copied a valid opencv from my friend's mac, but the imwrite function is still not found on my mac

Please help.

bash: g++ $(pkg-config --cflags --libs opencv) BoxFilter.cc -o BoxFilter
In file included from /usr/local/Cellar/opencv/3.3.0_3/include/opencv2/core.hpp:54:0,
                from /usr/local/Cellar/opencv/3.3.0_3/include/opencv2/opencv.hpp:52,
                from BoxFilter.cc:2:
/usr/local/Cellar/opencv/3.3.0_3/include/opencv2/core/base.hpp:354:35: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
#   pragma GCC diagnostic ignored "-Winvalid-noreturn"
                                ^
Undefined symbols for architecture x86_64:
"cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)",referenced from:
    _main in ccO7bsE6.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
baNv
  • 493
  • 1
  • 4
  • 12
  • [Your linkage consumes libraries before the object files that refer to them](https://stackoverflow.com/a/43305704/1362568) – Mike Kinghan Mar 20 '18 at 12:15
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Mike Kinghan Mar 20 '18 at 12:15
  • I think @MikeKinghan is suggesting you re-order your parameters to `g++` such that `$(pkg-config...)` comes at the rightmost end of the line... – Mark Setchell Sep 11 '18 at 13:32

0 Answers0