4

I am working on opencv, Qt application on my mac computer, however, the compiling gives me the error like

Undefined symbols for architecture x86_64

I founder the solution from here, Qt5.1/Qt5.2 + Mac OS 10.9 (Mavericks) + XCode 5.0.2, Undefined symbols for architecture x86_64

that I changed /usr/local/Cellar/qt5/5.3.2/mkspecs/macx-clang/qmake.conf

from

QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6

to

QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9

after cleaning the project, it doesn't work, I wonder any other to change ?

///// update ////

previously i found my default kit used the g++ as the compiler and now I changed to clang as the default compiler, you can see my config here https://www.dropbox.com/s/93viwvf1a70s347/Screenshot%202015-02-13%2002.43.23.png?dl=0

but what is getting wired, the error 'Undefined symbols for architecture x86_64' still exist and also there is another error saying: error: linker command failed with exit code 1 (use -v to see invocation)

what is wrong??

/// update ////

#-------------------------------------------------
#
# Project created by QtCreator 2014-06-08T01:54:11
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets webkitwidgets

TARGET = particle_filter
TEMPLATE = app
QT += network

SOURCES += main.cpp\

HEADERS  += \


FORMS    += \
    parkingapp.ui \

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

INCLUDEPATH += /usr/local/Cellar/opencv/2.4.9/include

LIBS += -L/usr/local/Cellar/opencv/2.4.9/lib \
-lopencv_core \
-lopencv_highgui \
-lopencv_imgproc \
-lopencv_video \
-lopencv_objdetect \
-lopencv_ml \
-lopencv_features2d
#-------------------------------------------------

later i found this http://qt-project.org/forums/viewthread/24551/P15, so I added this to the end of my .pro

LIBS += -stdlib=libc++

QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -mmacosx-version-min=10.9
QMAKE_LFLAGS += -mmacosx-version-min=10.9

but still don't work .... :(

Community
  • 1
  • 1
user824624
  • 7,077
  • 27
  • 106
  • 183
  • Did you entirely remove your build directories? – Simon Warta Feb 11 '15 at 20:47
  • Hi,Simon, I tried to remove the folder and rebuild again, but still not working. So far I only changed the qmake.conf in the macx-clang, which the clang64bit compiler for QT. but I am not sure whether I am truly using clang compiler or g++ compiler, it could be a issue, what do you think, I am trying out on this – user824624 Feb 11 '15 at 21:03
  • when I go to QT preference compilers section, I can see gcc 32bit , gcc 64 bit, clang 32 bit, clang 64bit auto detected, but which one I am using exactly,how do I check which compiler I am using – user824624 Feb 11 '15 at 21:06
  • Are you using Qt Creator? You can check which compiler is used in the tab "[4] Compile". You might need to add https://gist.github.com/webmaster128/d26e2bc1b8ef4d91a459 in your .pro file too – Simon Warta Feb 11 '15 at 21:09
  • I am using QT creator, I shared the snapshot of my config to you, https://www.dropbox.com/s/sits5nkqyga0ahc/Screenshot%202015-02-11%2021.22.35.png?dl=0, it seems to me that the compiler is g++, so I changed the macx-clang-32/qmake.conf, QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9, removed the old build , added the things you mentoned in the .pro. but still not working – user824624 Feb 11 '15 at 21:27
  • Well, you cannot use clang Qt libraries with g++. Which compiler version of Qt did you install? – Simon Warta Feb 11 '15 at 21:49
  • here is the snapshot of QT version and available compiler, https://www.dropbox.com/s/rfnjmqswu60a3d0/Screenshot%202015-02-11%2021.55.15.png?dl=0, https://www.dropbox.com/s/6po11quhggo2w4l/Screenshot%202015-02-11%2021.55.06.png?dl=0, but I don't know how to set the compiler in my project setting – user824624 Feb 11 '15 at 21:58
  • You connect a Qt installation and a compiler together in a kit. See the "Kits" tab. – Simon Warta Feb 11 '15 at 22:28

1 Answers1

5
Undefined symbols for architecture x86_64

This means that compiler couldn't solve address for symbols.

So you have a need to add libraries for that symbols in your pro. file.

For example,

LIBS += -framework AppKit
LIBS += -framework CoreAudio
LIBS += -framework AudioToolbox

Check your project configure for libraries.

covernal
  • 329
  • 1
  • 3
  • 20
  • 3
    Click 'O' on the 'Undefined symbols for ...' issue in the Issue list of Qt Creator, then you can see compiler output. It will help you what is wrong. – covernal Feb 12 '15 at 13:52