I'm trying to build a GUI for a set of C++ files that I've been writing, and I decided to try Qt. However, trying to compile the files that I have added Qt components to has proven to be difficult. I'm using clang, with the invocation
clang++ -std=c++0x -stdlib=libc++ -framework QtGui F/Users/[uname]/Qt5.1.0/5.1.0/clang_64/lib -I/Users/[uname]/Qt5.1.0/5.1.0/clang_64/include -L/Users/[uname]/Qt5.1.0/5.1.0/clang_64/lib -o QT qt.cpp
And this works if I include just
#include "QtGui/QGuiApplication"
It seems like I should be should be using, though,
#include <QtGui/QApplication>
which fails with the error
fatal error: 'QtGui/QApplication' file not found
If I try to include the qpushbutton.h file, with
#include "QtWidgets/QPushButton"
I get an error:
clang++ -std=c++0x -stdlib=libc++ -framework QtGui -F/Users/[uname]/Qt5.1.0/5.1.0/clang_64/lib -I/Users/[uname]/Qt5.1.0/5.1.0/clang_64/include -L/Users/[uname]/Qt5.1.0/5.1.0/clang_64/lib -v -o QT qt.cpp
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
"/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.7.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name qt.cpp -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 136 -v -resource-dir /usr/bin/../lib/clang/4.2 -F/Users/[uname]/Qt5.1.0/5.1.0/clang_64/lib -I /Users/[uname]/Qt5.1.0/5.1.0/clang_64/include -fmodule-cache-path /var/folders/lw/wq_l1f1936q0dmc1b_tkp94m0000gn/T/clang-module-cache -stdlib=libc++ -std=c++0x -fdeprecated-macro -fdebug-compilation-dir "[path]" -ferror-limit 19 -fmessage-length 204 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.7.0 -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/lw/wq_l1f1936q0dmc1b_tkp94m0000gn/T/qt-YxX3PY.o -x c++ qt.cpp
clang -cc1 version 4.2 based upon LLVM 3.2svn default target x86_64-apple-darwin11.4.2
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
/Users/[uname]/Qt5.1.0/5.1.0/clang_64/lib (framework directory)
/Users/[uname]/Qt5.1.0/5.1.0/clang_64/include
/usr/bin/../lib/c++/v1
/usr/local/include
/usr/bin/../lib/clang/4.2/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.7.0 -o QT -lcrt1.10.6.o -L/Users/[uname]/Qt5.1.0/5.1.0/clang_64/lib -framework QtGui /var/folders/lw/wq_l1f1936q0dmc1b_tkp94m0000gn/T/qt-YxX3PY.o -lc++ -lSystem /usr/bin/../lib/clang/4.2/lib/darwin/libclang_rt.osx.a -F/Users/[uname]/Qt5.1.0/5.1.0/clang_64/lib
Undefined symbols for architecture x86_64:
"QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)", referenced from:
QTypedArrayData<unsigned short>::deallocate(QArrayData*) in qt-YxX3PY.o
"QPushButton::QPushButton(QString const&, QWidget*)", referenced from:
_main in qt-YxX3PY.o
"QPushButton::~QPushButton()", referenced from:
_main in qt-YxX3PY.o
"QString::fromAscii_helper(char const*, int)", referenced from:
QString::QString(char const*) in qt-YxX3PY.o
"QWidget::show()", referenced from:
_main in qt-YxX3PY.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I also have been trying qmake, which fails from the same missing symbols from the x86_64 architecture as above, with the qt.pro file being
QT += core
QT += gui
SOURCE += qt.cpp
The qt.cpp file itself is just a sample:
#include <QtGui/QApplication>
#include <QtGui/QPushButton>
int main(int argc, char* argv[]){
QApplication app(argc, argv);
QPushButton but ("Button");
but.show();
return app.exec();
}
The files I'm working with need to be compiled in the C++11 standard and I really don't want to switch IDEs, so Qt Creator is not an ideal solution (Qt Creator also generates the missing symbols error).
I'm sure there's something obvious I'm missing, but I need to continue work on the non-GUI aspects of the project ASAP.
I'm running Mac OS 10.7.5 on a MacBook Air 64bit. I installed Qt5.1.0 from the Mac Installer offered on the Qt site. My clang++ version is 4.2 (clang-425.0.28), installed via command line tools in XCode.
Thanks in advance.