Important: Please read the Qt Code of Conduct -

Symbols not found in architecture x86_64

    :-1: error: symbol(s) not found for architecture x86_64:-
    1: error: linker command failed with exit code 1 (use -v to see invocation)

    Im desperately trying to get my code running this is an integration with openCV , could someone please help explain these errors to me or why my code doesn't work? thanks in advance; I'm using opencv 3.1.0

    #include "mainwindow.h"
    #include <QApplication>
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/videoio/videoio.hpp>
    #include <iostream>
    using namespace cv;
    using namespace std;
    CascadeClassifier face_cascade;
    void detectFaces(Mat frame) {
      vector<Rect> faces;
      Mat frame_gray;
      cvtColor(frame, frame_gray, COLOR_BGR2GRAY);  // Convert to gray scale
      equalizeHist(frame_gray, frame_gray);   	// Equalize histogram
      // Detect faces
      face_cascade.detectMultiScale(frame_gray, faces, 1.1, 3,
                    0|CASCADE_SCALE_IMAGE, Size(30, 30));
      // Iterate over all of the faces
      for( size_t i = 0; i < faces.size(); i++ ) {
        // Find center of faces
        Point center(faces[i].x + faces[i].width/2, faces[i].y + faces[i].height/2);
        // Draw ellipse around face
        ellipse(frame, center, Size(faces[i].width/2, faces[i].height/2),
            0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
      imshow( "window",frame);  // Display frame
    int main(int argc, char *argv[]){
        QApplication a(argc, argv);
        MainWindow w;
     // cam code
            VideoCapture cap(0);        // Open default camera
              Mat frame;
              // Load preconstructed classifier
              while( {
                detectFaces(frame);       // Call function to detect faces
                if( waitKey(30) >= 0)     // Pause key
    }catch(Exception ex){
    std::cout << "Unable to initiate camera" << std::endl;
        //end cam code
    return a.exec();

  • Lifetime Qt Champion


    What symbols are missing ?

    Are you sure you have linked to all the necessary libs ?

    Are they of the correct architecture ?

  • This is my PRO file below, thanks for your reply; Im not quite sure i really don't understand whats going on, I have been able to get the live camera feed from my code but when implementing the face detection in openCV I am getting this issue .pro file as follows:

    # Project created by QtCreator 2016-05-25T01:38:34
    QT       += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = Origin
    TEMPLATE = app
    SOURCES += main.cpp\
    LIBS += \
    -L/usr/local/lib \
    -lopencv_core \
    -lopencv_highgui \
    -lopencv_videoio \
    HEADERS  += mainwindow.h
    FORMS    += mainwindow.ui

  • Lifetime Qt Champion

    Looks fine but again: what symbols are missing ?

  • Symbols in what context? Im fairly new to Qt apologies for being a little slow in advance but this is my compile output:
    If you are asking a specific question ill gladly get the info needed if you could just show me where i can find this, thanks again for your help

    16:32:52: Running steps for project Origin...
    16:32:52: Configuration unchanged, skipping qmake step.
    16:32:52: Starting: "/usr/bin/make" 
    /Applications/ -c -pipe -stdlib=libc++ -g -std=gnu++11 -isysroot /Applications/ -mmacosx-version-min=10.7 -Wall -W -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../Origin -I. -I/usr/local/include -I../../Qt/5.6/clang_64/lib/QtWidgets.framework/Headers -I../../Qt/5.6/clang_64/lib/QtGui.framework/Headers -I../../Qt/5.6/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/ -I/Applications/ -I. -I../../Qt/5.6/clang_64/mkspecs/macx-clang -F/Users/travishaycock/Qt/5.6/clang_64/lib -o main.o ../Origin/main.cpp
    /Applications/ -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,/Applications/ -mmacosx-version-min=10.7 -Wl,-rpath,/Users/travishaycock/Qt/5.6/clang_64/lib -o main.o mainwindow.o moc_mainwindow.o   -F/Users/travishaycock/Qt/5.6/clang_64/lib -L/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_videoio -lopencv_objdetect -framework QtWidgets -framework QtGui -framework QtCore -framework OpenGL -framework AGL 
    Undefined symbols for architecture x86_64:
      "cv::equalizeHist(cv::_InputArray const&, cv::_OutputArray const&)", referenced from:
          detectFaces(cv::Mat) in main.o
      "cv::ellipse(cv::_InputOutputArray const&, cv::Point_<int>, cv::Size_<int>, double, double, double, cv::Scalar_<double> const&, int, int, int)", referenced from:
          detectFaces(cv::Mat) in main.o
      "cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)", referenced from:
          detectFaces(cv::Mat) 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: *** [] Error 1
    16:32:55: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project Origin (kit: Desktop Qt 5.6.0 clang 64bit)
    When executing step "Make"
    16:32:55: Elapsed time: 00:03.

  • Lifetime Qt Champion

    That's nothing Qt specific, it's standard C++.

    You are not linking to the OpenCV module that provides these symbols. For example equalizeHist comes from imgproc

  • This post is deleted!

Log in to reply