Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [Solved]Issues with OpenCV - Error message: symbol(s) not found for architecture x86_64
Forum Updated to NodeBB v4.3 + New Features

[Solved]Issues with OpenCV - Error message: symbol(s) not found for architecture x86_64

Scheduled Pinned Locked Moved Qt Creator and other tools
7 Posts 2 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    joned
    wrote on last edited by
    #1

    After 4 hours of struggling with linking problems with openCV I finally made it to locate them.
    When I try testing it with something simple as showing a simple image, i get this error message which doesn't make sence. I know it has to do with openCV, because something as simple as "hello world" runs easily.

    my .pro looks like this
    @#-------------------------------------------------

    Project created by QtCreator 2015-01-23T19:58:31

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = TEST
    TEMPLATE = app

    INCLUDEPATH += /usr/local/include

    HEADERS += mainwindow.h

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

    SOURCES += main.cpp
    mainwindow.cpp

    FORMS += mainwindow.ui
    @

    mainwindow.h
    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    private:
    Ui::MainWindow *ui;
    };

    #endif // MAINWINDOW_H
    @
    main.cpp
    @#include "mainwindow.h"
    #include <QApplication>
    #include <QString>
    #include <iostream>
    #include <opencv/cv.h>
    #include <opencv/highgui.h>

    int main(int argc, char argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    std::cout << "hello world - lalala" << std::endl;
    IplImage
    img = 0;
    img = cvLoadImage("/users/horse.jpg");
    cvNamedWindow("Exmaple1", CV_WINDOW_AUTOSIZE);
    cvShowImage("Exmaple1",img);
    cvWaitKey(0);
    cvReleaseImage(&img);
    cvDestroyWindow("Example1");
    return a.exec();
    }
    @
    mainwindow.cpp
    @#include "mainwindow.h"
    #include "ui_mainwindow.h"
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    @
    mainwindow.ui
    @<?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
    <class>MainWindow</class>
    <widget class="QMainWindow" name="MainWindow">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>797</width>
    <height>525</height>
    </rect>
    </property>
    <property name="windowTitle">
    <string>MainWindow</string>
    </property>
    <widget class="QWidget" name="centralWidget">
    <widget class="QPushButton" name="pushButton">
    <property name="geometry">
    <rect>
    <x>350</x>
    <y>330</y>
    <width>113</width>
    <height>32</height>
    </rect>
    </property>
    <property name="text">
    <string>done</string>
    </property>
    </widget>
    <widget class="QGraphicsView" name="input">
    <property name="geometry">
    <rect>
    <x>50</x>
    <y>70</y>
    <width>256</width>
    <height>192</height>
    </rect>
    </property>
    </widget>
    <widget class="QGraphicsView" name="output">
    <property name="geometry">
    <rect>
    <x>490</x>
    <y>70</y>
    <width>256</width>
    <height>192</height>
    </rect>
    </property>
    </widget>
    </widget>
    <widget class="QMenuBar" name="menuBar">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>797</width>
    <height>22</height>
    </rect>
    </property>
    <widget class="QMenu" name="menuOpenCV">
    <property name="title">
    <string>OpenCV</string>
    </property>
    </widget>
    <addaction name="menuOpenCV"/>
    </widget>
    <widget class="QToolBar" name="mainToolBar">
    <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
    </attribute>
    <attribute name="toolBarBreak">
    <bool>false</bool>
    </attribute>
    </widget>
    <widget class="QStatusBar" name="statusBar"/>
    </widget>
    <layoutdefault spacing="6" margin="11"/>
    <resources/>
    <connections/>
    </ui>
    @

    The error message i get is this..

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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Are both OpenCV and Qt built for 64 bit ?

      If so, what symbols are missing ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        joned
        wrote on last edited by
        #3

        I don't know either which symbols should be missing...
        The Qt it built using 64 bit, i am not sure about the openCV though.. I have 2 version of openCV one from Macports, and the other one is compiled using cmake which is the one i am linking to in my .pro.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The error message should contain a list of the missing symbols

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • J Offline
            J Offline
            joned
            wrote on last edited by
            #5

            @01:42:53: Running steps for project test...
            01:42:53: Configuration unchanged, skipping qmake step.
            01:42:53: Starting: "/usr/bin/make"
            /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -mmacosx-version-min=10.7 -Wl,-rpath,/Users/keerthikanratnarajah/Qt/5.4/clang_64/lib -o test.app/Contents/MacOS/test main.o mainwindow.o moc_mainwindow.o -F/Users/keerthikanratnarajah/Qt/5.4/clang_64/lib -L/usr/local/lib -lopencv_core -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL
            Undefined symbols for architecture x86_64:
            "_cvDestroyWindow", referenced from:
            _main in main.o
            "_cvLoadImage", referenced from:
            _main in main.o
            "_cvNamedWindow", referenced from:
            _main in main.o
            "_cvShowImage", referenced from:
            _main in main.o
            "_cvWaitKey", 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: *** [test.app/Contents/MacOS/test] Error 1
            01:42:53: The process "/usr/bin/make" exited with code 2.
            Error while building/deploying project test (kit: Desktop Qt 5.4.0 clang 64bit)
            When executing step "Make"
            01:42:53: Elapsed time: 00:00.@

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Your pro file is wrong

              @
              LIBS += -L/usr/local/lib
              -lopencv_core
              -lopencv_imgcodecs
              -lopencv_highgui
              @

              should be

              @
              LIBS += -L/usr/local/lib
              -lopencv_core
              -lopencv_imgcodecs
              -lopencv_highgui
              @

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • J Offline
                J Offline
                joned
                wrote on last edited by
                #7

                I found the solution..

                https://qt-project.org/forums/viewthread/35646

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved