我安装了Qt并尝试在QtCreator中构建模板项目(Qt4 Gui Application)。我无法弄清楚为什么我会收到这些错误。
Running build steps for project SourceControl... Configuration unchanged, skipping QMake step. Starting: /usr/bin/make -w make: Entering directory `/Users/jason/SourceControl' g++ -c -pipe -g -gdwarf-2 -Wall -W -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.5/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtNetwork.framework/Versions/4/Headers -I/usr/include/QtNetwork -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I. -I. -F/Library/Frameworks -o main.o main.cpp In file included from /Library/Frameworks/QtCore.framework/Headers/qnamespace.h:45, from /Library/Frameworks/QtCore.framework/Headers/qobjectdefs.h:45, from /Library/Frameworks/QtCore.framework/Headers/qobject.h:47, from /Library/Frameworks/QtCore.framework/Headers/qcoreapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/qapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/QApplication:1, from main.cpp:1: /Library/Frameworks/QtCore.framework/Headers/qglobal.h:297:34: error: AvailabilityMacros.h: No such file or directory In file included from /Library/Frameworks/QtCore.framework/Headers/qstring.h:46, from /Library/Frameworks/QtCore.framework/Headers/qobject.h:48, from /Library/Frameworks/QtCore.framework/Headers/qcoreapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/qapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/QApplication:1, from main.cpp:1: /Library/Frameworks/QtCore.framework/Headers/qbytearray.h:48:20: error: string.h: No such file or directory In file included from /Library/Frameworks/QtCore.framework/Headers/qobject.h:48, from /Library/Frameworks/QtCore.framework/Headers/qcoreapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/qapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/QApplication:1, from main.cpp:1: /Library/Frameworks/QtCore.framework/Headers/qstring.h:60:22: error: string: No such file or directory In file included from /Library/Frameworks/QtCore.framework/Headers/qobject.h:50, from /Library/Frameworks/QtCore.framework/Headers/qcoreapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/qapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/QApplication:1, from main.cpp:1: /Library/Frameworks/QtCore.framework/Headers/qlist.h:50:20: error: iterator: No such file or directory /Library/Frameworks/QtCore.framework/Headers/qlist.h:51:16: error: list: No such file or directory /Library/Frameworks/QtCore.framework/Headers/qlist.h:54:15: error: new: No such file or directory In file included from /Library/Frameworks/QtGui.framework/Headers/qbrush.h:47, from /Library/Frameworks/QtGui.framework/Headers/qpalette.h:47, from /Library/Frameworks/QtGui.framework/Headers/qwidget.h:48, from /Library/Frameworks/QtGui.framework/Headers/qmainwindow.h:45, from /Library/Frameworks/QtGui.framework/Headers/QMainWindow:1, from mainwindow.h:4, from main.cpp:2: /Library/Frameworks/QtCore.framework/Headers/qvector.h:52:18: error: vector: No such file or directory /Library/Frameworks/QtCore.framework/Headers/qvector.h:54:20: error: stdlib.h: No such file or directory In file included from /Library/Frameworks/QtCore.framework/Headers/qstring.h:46, from /Library/Frameworks/QtCore.framework/Headers/qobject.h:48, from /Library/Frameworks/QtCore.framework/Headers/qcoreapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/qapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/QApplication:1, from main.cpp:1: /Library/Frameworks/QtCore.framework/Headers/qbytearray.h: In function 'uint qstrlen(const char*)': /Library/Frameworks/QtCore.framework/Headers/qbytearray.h:68: error: 'strlen' was not declared in this scope /Library/Frameworks/QtCore.framework/Headers/qbytearray.h: In function 'int qstrncmp(const char*, const char*, uint)': /Library/Frameworks/QtCore.framework/Headers/qbytearray.h:91: error: 'strncmp' was not declared in this scope /Library/Frameworks/QtCore.framework/Headers/qbytearray.h: In function 'bool operator==(const QByteArray&, const QByteArray&)': /Library/Frameworks/QtCore.framework/Headers/qbytearray.h:502: error: 'memcmp' was not declared in this scope In file included from /Library/Frameworks/QtCore.framework/Headers/qobject.h:48, from /Library/Frameworks/QtCore.framework/Headers/qcoreapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/qapplication.h:45, from /Library/Frameworks/QtGui.framework/Headers/QApplication:1, from main.cpp:1: /Library/Frameworks/QtCore.framework/Headers/qstring.h: At global scope: /Library/Frameworks/QtCore.framework/Headers/qstring.h:65: error: expected initializer before ' QList::fromStdList()': /Library/Frameworks/QtCore.framework/Headers/qlist.h:316: error: 'list' was not declared in this scope /Library/Frameworks/QtCore.framework/Headers/qlist.h:316: error: 'back_inserter' is not a member of 'std' In file included from /Library/Frameworks/QtGui.framework/Headers/qbrush.h:47, from /Library/Frameworks/QtGui.framework/Headers/qpalette.h:47, from /Library/Frameworks/QtGui.framework/Headers/qwidget.h:48, from /Library/Frameworks/QtGui.framework/Headers/qmainwindow.h:45, from /Library/Frameworks/QtGui.framework/Headers/QMainWindow:1, from mainwindow.h:4, from main.cpp:2: /Library/Frameworks/QtCore.framework/Headers/qvector.h: At global scope: /Library/Frameworks/QtCore.framework/Headers/qvector.h:293: error: expected unqualified-id before ' QVector::fromStdVector()': /Library/Frameworks/QtCore.framework/Headers/qvector.h:294: error: 'vector' was not declared in this scope /Library/Frameworks/QtCore.framework/Headers/qvector.h:294: error: 'back_inserter' is not a member of 'std' /Library/Frameworks/QtCore.framework/Headers/qvector.h: In constructor 'QVector::QVector(int) [with T = QPoint]': /Library/Frameworks/QtGui.framework/Headers/qpolygon.h:93: instantiated from here /Library/Frameworks/QtCore.framework/Headers/qvector.h:397: error: no matching function for call to 'operator new(long unsigned int, QPoint*&)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qvector.h: In constructor 'QVector::QVector(int) [with T = QPointF]': /Library/Frameworks/QtGui.framework/Headers/qpolygon.h:152: instantiated from here /Library/Frameworks/QtCore.framework/Headers/qvector.h:397: error: no matching function for call to 'operator new(long unsigned int, QPointF*&)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qlist.h: In member function 'void QList::node_construct(QList::Node*, const T&) [with T = QString]': /Library/Frameworks/QtCore.framework/Headers/qlist.h:426: instantiated from 'void QList::append(const T&) [with T = QString]' /Library/Frameworks/QtCore.framework/Headers/qstringlist.h:70: instantiated from here /Library/Frameworks/QtCore.framework/Headers/qlist.h:341: error: no matching function for call to 'operator new(long unsigned int, QList::Node*&)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qlist.h: In member function 'void QList::node_copy(QList::Node*, QList::Node*, QList::Node*) [with T = QString]': /Library/Frameworks/QtCore.framework/Headers/qlist.h:618: instantiated from 'QList& QList::operator+=(const QList&) [with T = QString]' /Library/Frameworks/QtCore.framework/Headers/qstringlist.h:85: instantiated from here /Library/Frameworks/QtCore.framework/Headers/qlist.h:360: error: no matching function for call to 'operator new(long unsigned int, QList::Node*)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qvector.h: In member function 'void QVector::realloc(int, int) [with T = QPoint]': /Library/Frameworks/QtCore.framework/Headers/qvector.h:315: instantiated from 'void QVector::detach_helper() [with T = QPoint]' /Library/Frameworks/QtCore.framework/Headers/qvector.h:113: instantiated from 'QVector::QVector(const QVector&) [with T = QPoint]' /Library/Frameworks/QtGui.framework/Headers/qpolygon.h:66: instantiated from here /Library/Frameworks/QtCore.framework/Headers/qvector.h:444: error: no matching function for call to 'operator new(long unsigned int, QPoint*&)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qvector.h:484: error: no matching function for call to 'operator new(long unsigned int, QPoint*&)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qvector.h:491: error: no matching function for call to 'operator new(long unsigned int, QPoint*&)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qvector.h: In member function 'void QVector::realloc(int, int) [with T = QPointF]': /Library/Frameworks/QtCore.framework/Headers/qvector.h:315: instantiated from 'void QVector::detach_helper() [with T = QPointF]' /Library/Frameworks/QtCore.framework/Headers/qvector.h:113: instantiated from 'QVector::QVector(const QVector&) [with T = QPointF]' /Library/Frameworks/QtGui.framework/Headers/qpolygon.h:131: instantiated from here /Library/Frameworks/QtCore.framework/Headers/qvector.h:444: error: no matching function for call to 'operator new(long unsigned int, QPointF*&)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qvector.h:484: error: no matching function for call to 'operator new(long unsigned int, QPointF*&)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qvector.h:491: error: no matching function for call to 'operator new(long unsigned int, QPointF*&)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qvector.h: In member function 'void QVector::realloc(int, int) [with T = QPainterPath::Element]': /Library/Frameworks/QtCore.framework/Headers/qvector.h:315: instantiated from 'void QVector::detach_helper() [with T = QPainterPath::Element]' /Library/Frameworks/QtCore.framework/Headers/qvector.h:129: instantiated from 'void QVector::detach() [with T = QPainterPath::Element]' /Library/Frameworks/QtCore.framework/Headers/qvector.h:228: instantiated from 'T* QVector::begin() [with T = QPainterPath::Element]' /Library/Frameworks/QtCore.framework/Headers/qvector.h:241: instantiated from 'T& QVector::first() [with T = QPainterPath::Element]' /Library/Frameworks/QtGui.framework/Headers/qpainterpath.h:370: instantiated from here /Library/Frameworks/QtCore.framework/Headers/qvector.h:444: error: no matching function for call to 'operator new(long unsigned int, QPainterPath::Element*&)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qvector.h:315: instantiated from 'void QVector::detach_helper() [with T = QPainterPath::Element]' /Library/Frameworks/QtCore.framework/Headers/qvector.h:129: instantiated from 'void QVector::detach() [with T = QPainterPath::Element]' /Library/Frameworks/QtCore.framework/Headers/qvector.h:228: instantiated from 'T* QVector::begin() [with T = QPainterPath::Element]' /Library/Frameworks/QtCore.framework/Headers/qvector.h:241: instantiated from 'T& QVector::first() [with T = QPainterPath::Element]' /Library/Frameworks/QtGui.framework/Headers/qpainterpath.h:370: instantiated from here /Library/Frameworks/QtCore.framework/Headers/qvector.h:484: error: no matching function for call to 'operator new(long unsigned int, QPainterPath::Element*&)' :0: note: candidates are: void* operator new(long unsigned int) /Library/Frameworks/QtCore.framework/Headers/qvector.h:491: error: no matching function for call to 'operator new(long unsigned int, QPainterPath::Element*&)' :0: note: candidates are: void* operator new(long unsigned int) make: *** [main.o] Error 1 make: Leaving directory `/Users/jason/SourceControl' Exited with code 2. Error while building project SourceControl When executing build step 'Make'
答案 0 :(得分:3)
我不确定,但我猜你应该专注于第一个错误,它说它无法找到AvailabilityMacros.h。我认为应该在/ usr / include中,但我猜它可能不是因为你的编译行清楚地表明它是包含路径之一。
如果不存在,您可以尝试通过在命令行上使用find
找出它的位置,例如。
find /usr -name AvailabilityMacros.h
或Mac上可用的任何GUI方法(你可以告诉我,我不熟悉MacOS :))。顺便说一句,如果上述find
命令无效,那么您可以将搜索范围从/usr
扩展为/
。
回复您发布的find
结果:
您是否正在尝试针对MacOSX10.5.sdk构建应用程序?如果没有,那么我认为这不是你想要的版本。如果 使用10.5 SDK,则需要将QMAKE_MAC_SDK
qmake变量设置为/Developer/SDKs/MacOSX10.5.sdk。您可以在项目文件中执行此操作,也可以在Projects-> Build steps中将其设置为qmake的附加参数。
答案 1 :(得分:0)
谢谢Troubadour。我能够通过在项目的.pro文件中添加以下行来解决问题:
QMAKE_MAC_SDK = /Developer/SDKs/MacOSX10.5.sdk
我更愿意针对Mac OS X 10.6 SDK进行构建,但/ Developer / SDK中没有此类目录。如果您知道我在哪里可以找到10.6 SDK,请告诉我。
编辑:更新到最新版本的Xcode后,我能够从项目的.pro文件中删除上面指定的行并成功编译。