QT + Opencv on Mac Os 10.10.3 with error: Symbol(s) not found for Architecture x86_64

Asked

Viewed 211 times

8

I recently installed Qt Creator and Opencv. I was able to easily compile QT and Opencv separately. But I can’t compile both together. My file .pro is 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 Architecture x86_64":

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

I’ve done everything, all it’s kind of forum but none worked on my mac.

  • I once compiled from the terminal using the Cmakelists.txt file. And it’s in the /usr/local/lib folder

  • I am compiling for x86_64. I just added the INCLUDE you told me and I still get the same error.

  • Yes, the same mistake. I forgot to mention and after the x86_64 error, the error "error: Linker command failed with Exit code 1 (use -v to see Invocation)"

  • Pedro I offered a reward of 100 points to those who answer, hopefully this will help you get the desired answers. Good luck

  • What version of OSX and Xcode?

  • OS 10.10.3 and Xcode 6.3.1, but I’m using QT Creator

  • Try adding only the following to your . pro file: CONFIG += c++11. VERY IMPORTANT: Do not forget to clean and rebuild the project.

  • So, have you solved it? If not, I can also offer another reward to try to help.

Show 3 more comments

1 answer

1

Situations you can try for problem with Openvc:

  • Add to LDFLAGS as suggested in this reply Soen

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

Situations you may try for problems with MAC compiler:

  • Modify the QMAKE_MACOSX_DEPLOYMENT_TARGET, as suggested in Soen

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

    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
    

    for:

    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
    
  • Use QMAKE_CXXFLAGS and QMAKE_LFLAGS As stated 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
    }
    
  • I made and kept getting the same mistake.

  • You tried to edit the /Applications/Qt/5.4/clang_64/mkspecs/macx-clang/qmake.conf or did this just on . pro, try both?

  • I did both. both in qmake.conf and in . pro

  • It’s complicated rs... I don’t have a Mac to test, but I will try to find the answer, I believe that soon during the week can appear other answers. + 1 to your question

Browser other questions tagged

You are not signed in. Login or sign up in order to post.