I have asked this question in here
http://stackoverflow.com/questions/20342896/qt5-mac-os-10-9-mavericks-undefined-symbols-for-architecture-x86-64
I think the problem is the linker, so I post here again.
————————————————————
The computer is a “clean”(not upgraded) Mac OS X 10.9 + Xcode (5.0.2) with command line tools
I installed the Qt 5.2 (Qt5.1 has the same result), and a simple hello world c++ program runs nicely.
I have the OpenCV 2.4.7 and Boost 1.5 installed on my computer.
A simple program of OpenCV can be compiled and run normally under terminal
g++ -L/usr/local/lib -lopencv_core -lopencv_highgui -I/usr/local/include main.cpp
However when I try to build this program under Qt.
Qt gives me Undefined symbols for architecture x86_64
A simple boost:filesystem program gives the same error.
So it seems that Qt can’t link correctly to see the function I used ?
Here is the complete output of compile
10:31:18: Starting: "/usr/bin/make"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -g -gdwarf-2 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -Wall -W -fPIE -I/Users/ObiWang/Qt5.2.0/5.2.0-beta1/clang_64/mkspecs/macx-clang -I/Users/ObiWang/Desktop/untitled -I/usr/local/include -I. -o main.o /Users/ObiWang/Desktop/untitled/main.cpp
/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.9.sdk -mmacosx-version-min=10.6 -o untitled main.o -L/usr/local/lib -lopencv_core -lopencv_highgui
Undefined symbols for architecture x86_64:
"cv::imread(std::string const&, int)", 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: *** [untitled] Error 1
10:31:20: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled (kit: Desktop Qt 5.2.0 clang 64bit)
When executing step 'Make'
The project file is
INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib
LIBS += -lopencv_core -lopencv_highgui
cache()
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
The main.cpp is
#include <iostream>
#include "opencv2/highgui/highgui.hpp"
using namespace std ;
using namespace cv ;
int main()
{
Mat img ;
img = imread("image.jpg") ;
return 0;
}
—————————————————————-
I try to add this to project file
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
}
but nothing changed
I have been working on this more than four days.
Any ideas or directions are appreciated.
↧