Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Installing opencv

I has been a long time that I am trying to install opencv on my mac and work with qt creator and I am not successful. There are 2 errors which always there:

:-1: error: symbol(s) not found for architecture x86_64

:-1: error: linker command failed with exit code 1 (use -v to see invocation)

There are thousands of people with that problem and they could solve it as there are lots of answers and methods on the internet, but I couldnt solve mine. I tried to ask for help from professionals and they couldnt also solve it.

I tried to use PLplot library and I got the same errors.

My mac version in 10.11.3 OS X El Capitan. Using qt 5.3.1 and opencv version 3.0.0. The debugger is clang.


I really appreciate any help

MacBook Pro with Retina display, OS X El Capitan (10.11.3)

Posted on Feb 23, 2016 6:02 AM

Reply
14 replies

Feb 23, 2016 6:26 AM in response to sara_dn2016

That is actually just one error - it indicates that the linker failed to find some code that should be there. Why that is I can't say, at least not without further information. When compiling software from source, as you are, there are often many dependencies - meaning that the software that you are trying to compile requires some other library(ies) to be present, and sometimes you go and try to install one and there is another dependency and so on.


I am not familiar with this particular software, and I cannot go through the paces of trying an install right now, but if you give more detailed information about the very steps you've taken and the exact wording of the error messages I might be able to give some assistance.

Feb 23, 2016 6:39 AM in response to Luis Sequeira1

Thanks for your answer. I dont know what details do you mean. But here is what I have done so far:

Opencv is a library for image processing. The installation for mac, windows and linux is already on the internet and its easy to do it, I tried macport for installation. Using qt creator 5.3.1 and using CMake application. the compiler is clang x86 64 bit and 32 bit. For including the libraries in the code, the I need to add those lines to .pro file


LIBS+=-L/usr/local/lib/-lopencv_core-lopencv_highgui-lopencv_imgproc

INCLUDEPATH+=/usr/local/include/

By adding those to .pro file, the libraries are already included in program and I can include them. When I add one line of code to read an image the errors pops up.


Matdata=imread("/Usr/Sara/Desktop/Bild.jpg");

Feb 23, 2016 6:48 AM in response to sara_dn2016

So if I understand correctly, you do NOT see an error when compiling or installing opencv, but when USING it.


It seems like you are failing to link the opencv library with your own code (I assume that the line


Matdata=imread("/Usr/Sara/Desktop/Bild.jpg");


is code in your program. It appears to be valid C code (and valid in C++ and Objective C as well).


Are you compiling YOUR code with CMake?

What is the detailed error message?

Feb 23, 2016 6:58 AM in response to Luis Sequeira1

Yes, the installing and compiling is fine, even including libraries is fine. but I cant use it.

I linked CMake application to qt creator so it creates the CMake file automatically. Here is the complete code.


#include <opencv2/highgui/highgui.hpp>

#include <opencv2/core/core.hpp>


int main(int argc, const char** argv )

{

cv::Mat image = cv::imread ("/Users/Sara/Desktop/Bild.jpg");

cv::namedWindow("OpenCV first Project");

cv::waitKey(5000);


return 1;

}


really simple coding for displaying an image.

There is no detail for the errors. Its only


User uploaded file

Feb 23, 2016 7:07 AM in response to sara_dn2016

In order to proceed I think the big question is: what are the symbol(s) that are not found? There must be a way to find that out.

When I see that error in XCode, I can look for the missing function or functions:


User uploaded file


What IDE are you using?


(Off-topic: the standard return value for a successful main() function is 0, not 1; that is the decades-old convention for signaling a normal exit from a program)

Feb 24, 2016 12:49 AM in response to Luis Sequeira1

Here are the details for error:

Undefined symbols for architecture x86_64:

"cv::imread(cv::String const&, int)", referenced from:

_main in main.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [MyProject] Error 1

09:45:57: The process "/usr/bin/make" exited with code 2.

Error while building/deploying project MyProject (kit: Desktop Qt 5.5.1 clang 64bit)

When executing step "Make"

Installing opencv

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.