我是QT的一名新手,甚至無法獲得開始的例子。問題是,即使QtCore沒有找到。認爲我的道路有問題或者沒有使用正確的版本?錯誤的幫助Qt入門
#include <QtCore>
#include <iostream>
#include <QtXml/QXmlSimpleReader>
int main(int argc, char *argv[])
{
QDir xmldir("/xxx/xxx");
QXmlSimpleReader xmlReader;
}
實施例是: /Users/frank/xxx-build-desktop/../xxx/main.cpp:1:錯誤:QtCore:沒有這樣的文件或目錄。
經過的路徑和qmake的路徑是/ usr/bin中/ QMAKE 如果我運行的qmake -v這是印刷:
QMake version 2.01a
Using Qt version 4.7.0 in /Library/Frameworks
我使用的是Mac 10.6.6 任何答覆可以理解的。
下面是工程文件:
QT += core gui
QT += xml
QT += webkit
QT += xmlpatterns
TARGET = xxx
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
結果從化妝:
iMac:~/xxx/ qmake -spec macx-g++
iMac:~/xxx/ ls -ltr
total 56
-rw-rw---- 1 frank staff 349 Feb 5 16:06 xxx.pro
-rw-rw---- 1 frank staff 3875 Feb 6 12:56 main.cpp
-rw-rw---- 1 frank staff 7985 Feb 6 12:56 xxx.pro.user
-rw-rw---- 1 frank staff 8974 Feb 6 12:56 Makefile
iMac:~/xxx/ make
g++ -c -pipe -g -gdwarf-2 -Wall -W -DQT_WEBKIT_LIB -DQT_XMLPATTERNS_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.7/mkspecs/macx-g++ -I. -I. -I/usr/include/QtCore -I. -I/usr/include/QtGui -I. -I/usr/include/QtXml -I. -I/usr/include/QtXmlPatterns -I. -I/usr/include/QtWebKit -I/usr/include -I. -F/Library/Frameworks -o main.o main.cpp
main.cpp:1:18: error: QtCore: No such file or directory
main.cpp: In function ‘int main(int, char**)’:
main.cpp:27: error: ‘QDir’ was not declared in this scope
main.cpp:27: error: expected `;' before ‘xmldir’
main.cpp:28: error: ‘xmldir’ was not declared in this scope
main.cpp:28: error: ‘QDir’ is not a class or namespace
main.cpp:28: error: ‘QDir’ is not a class or namespace
main.cpp:28: error: ‘QDir’ is not a class or namespace
main.cpp: At global scope:
main.cpp:25: warning: unused parameter ‘argc’
main.cpp:25: warning: unused parameter ‘argv’
main.cpp:63: warning: unused parameter ‘namespaceURI’
main.cpp:63: warning: unused parameter ‘localName’
main.cpp:63: warning: unused parameter ‘qName’
main.cpp:67: warning: unused parameter ‘namespaceURI’
main.cpp:67: warning: unused parameter ‘localName’
make: *** [main.o] Error 1
iMac:~/xxx/
當你運行make時,它應該打印正在執行的命令(不知道它是否在Mac上執行它),編譯命令是什麼?它是否包含Qt包含目錄的正確路徑? – 2011-02-04 16:28:58
您是指「/ usr/bin/qmake」,它是指定爲PATH的原因。 – user3111525 2011-02-04 16:55:13
@frankmoss,我在問你在qmake之後運行make時會發生什麼(如果你不使用像Qt Creator這樣的IDE,通常的編譯過程)。但是,我甚至不確定在Mac上有什麼類似的東西。我讀了一些叫做XCode的東西。所以我不能在這裏幫助,因爲我不知道使用的構建系統的細節。 – 2011-02-04 18:36:26