前提・実現したいこと
macOS 10.15.3 Beta
opencv は Homebrew を使ってインストールしました。
C++ でopencv4 ライブラリを用いてMat型変数を宣言したいです。
宣言した後、同じディレクトリ内にあるjpg画像を読み込みたいです。
エラーメッセージを調べたのですが、明確な解決策が見当たりませんでした。
エラーメッセージの意味・解決方法がわかる方がいましたら是非教えていただけると助かります。
発生している問題・エラーメッセージ
$ g++ -std=c++11 main.cpp -o sample -I /usr/local/include/opencv4/ Undefined symbols for architecture x86_64: "cv::Mat::deallocate()", referenced from: cv::Mat::release() in main-fff43a.o "cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from: _main in main-fff43a.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 main-fff43a.o "cv::waitKey(int)", referenced from: _main in main-fff43a.o "cv::fastFree(void*)", referenced from: cv::Mat::operator=(cv::Mat&&) in main-fff43a.o cv::Mat::~Mat() in main-fff43a.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
該当のソースコード
c++
1```#include <opencv2/opencv.hpp> 2 3using namespace std; 4using namespace cv; 5 6int main() { 7 Mat img; 8 9 img = imread("suwawachan.jpg", IMREAD_UNCHANGED); 10 11 imshow("title", img); 12 waitKey(0); 13 14 return 0; 15}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/11 20:32