I have installed OpenCV via homebrew, for my Mac OSX.
The problem I am having is that I am unable to use the imread
openCV command at all. When I do, I get an error. Here is a breakdown of what I have done.
My simple code is:
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat imageMe = imread("frog.jpg", 0);
return 0;
}
To compile, I type this into the command prompt:
g++ opencvEntry.cpp -o opencvEntry `pkg-config --cflags --libs opencv` && ./opencvEntry
Upon doing that, the error message I get is:
Undefined symbols for architecture x86_64:
"cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
_main in ccvT5f6R.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
So... I am not sure where/what is going on here. If I simply uncomment the imread
line the file compiles just fine. However when uncommented, it does not recognize the command.
What is going on here?
I have the same issue, after searching, this is a solution which works for me, hope it can help you as well.
Compiling OpenCV code on a 64-bit mac
need LDFLAG of "-lopencv_imgproc".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.