Ask Your Question
1

Mac 10.10.4, opencv3.0 in qt creator can't use imwrite

asked 2015-08-06 03:55:10 -0600

charlesyin gravatar image

In my program, I want to use imwrite to save a picture, but I got two compile error, which says: error: symbol(s) not found for architecture x86_64 error: linker command failed with exit code 1 (use -v to see invocation) this is my program:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main()
{
cv::Mat image=cv::imread("/Users/yinxiangnan/Desktop/lena.jpg");
cv::namedWindow("My Image");
cv::Mat image1;
cv::flip(image,image1,1);
cv::imshow("My Image",image1);
cv::imwrite("/Users/yinxiangnan/Desktop/test.bmp",image1);
cv::waitKey(0);
return 0;
}

I can run the program in Xcode, and I can also run it after comment the imwrite line.

edit retag flag offensive close merge delete

Comments

Okay for a starter, you are using the wrong headers for OpenCV3.0

  • Change #include <opencv2/core/core.hpp> to #include <opencv2/core.hpp>
  • Change #include <opencv2/highgui/highgui.hpp> to #include <opencv2/highgui.hpp>

And then report back!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-08-06 04:04:52 -0600 )edit

Thank you, I changed it to what you said, but the error still exists

charlesyin gravatar imagecharlesyin ( 2015-08-06 04:35:33 -0600 )edit

Are you linking the correct OpenCV libraries?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-08-06 04:54:31 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-08-06 05:19:25 -0600

charlesyin gravatar image

By searching on the internet, I solved the problem. It's because the version of my Xcode is newer than the version defined in Qt3.0. So I have to modify the qmake.conf in the dirctory: ../Qt5.5.0/5.5/clang_64/mkspecs/macx-clang . After changed the QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 to QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.10 My program works well.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-08-06 03:48:24 -0600

Seen: 1,084 times

Last updated: Aug 06 '15