我是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