QT + OpenCV on Mac OS 10.10.3 com error: symbol (s) not found for architecture x86_64

8

I recently installed Qt Creator and OpenCv. I was able to quietly compile the separate QT and OpenCv. But I can not compile them together. My .pro file looks like this:

#-------------------------------------------------
#
# Project created by QtCreator 2015-06-27T12:52:47 
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Older
TEMPLATE = app


SOURCES += main.cpp\
    mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

INCLUDEPATH += /usr/local/include

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



QMAKE_CXXFLAGS+=-std=c++11
QMAKE_CXXFLAGS+=-stdlib=libc++

QMAKE_LFLAGS+=-std=c++11
QMAKE_LFLAGS+=-stdlib=libc++

QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7

The problem is that if I leave the main.cpp file this way compiles normally:

#include "mainwindow.h"
#include <QApplication>

#include <opencv2/opencv.hpp>


int main(int argc, char *argv[])
{



QApplication a(argc, argv);
MainWindow w;
w.show();

return a.exec();
}

If I add this single line I get the error "error: symbol (s) not found for x86_64 architecture" :

cv::Mat inputImage = cv::imread("/Users/pedrosoares/TESTEOpenCV/fefafofauroFex.png");

I've done everything, everything is kind of forum but none worked on my mac.

    
asked by anonymous 27.06.2015 / 19:27

1 answer

1

Situations you can try for the problem with OpenVC:

  • Add to LDFLAGS as suggested in this answer SOen

    LDFLAGS = -I/usr/local/include/opencv -lm -lopencv_core -lopencv_highgui -lopencv_video -lopencv_imgproc
    

Situations you might be trying to troubleshoot with the MAC compiler:

  • Modify QMAKE_MACOSX_DEPLOYMENT_TARGET , as suggested in SOen

    Edit /Applications/Qt/5.4/clang_64/mkspecs/macx-clang/qmake.conf and change the line:

    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
    

    by:

    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
    
  • Use QMAKE_CXXFLAGS and QMAKE_LFLAGS As this answer in the SOen :

    mac: CONFIG += MAC_CONFIG
    
    MAC_CONFIG {
        QMAKE_CXXFLAGS = -std=c++11 -stdlib=libstdc++ -mmacosx-version-min=10.7
        QMAKE_LFLAGS = -std=c++11 -stdlib=libstdc++ -mmacosx-version-min=10.7
    }
    
28.06.2015 / 04:42