QtCore: No such file or directory

系统环境:Fedora10

用QT编写程序,出现以下错误:

hello.h:4:17: error: QtCore: No such file or directoryhello.h:5:16: error: QtGui: No such file or directoryhello.h:12:23: error: QPixmapCache: No such file or directoryhello.h:13:18: error: QThread: No such file or directorymake: *** [hello.o] Error 1

写程序的方式是先创建一个文件夹,将所有的源文件

都放置在文件夹下,然后用qmake -project,生成pro工程文件,

用qmake来生成Makefile文件,然后make生成可执行文件,

但在make过程中发现出错,寻找了一下原因,发现用的编译器

版本不对,

qmake -v

然后会显示qmake版本为:

Qmake version: 1.07a (Qt 3.3.8b)Qmake is free software from Trolltech ASA.

qmake是QT3的编译器,,但需要的是QT4的编译器,在一个系统中

装了两个版本的QT,很难区分它们的编译器,导致程序编译出错,

后来寻找了一下QT4的编译器,应该用qmake-qt4命令来调用编译器

#qmake-qt4 -project

#qmake-qt4

#make

执行结果:

g++ -c -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector –param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include -I. -I. -I. -o main.o main.cpp/usr/lib/qt4/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include -I. -I. -I. hello.h -o moc_hello.cppg++ -c -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector –param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include -I. -I. -I. -o moc_hello.o moc_hello.cppg++ -o hello main.o moc_hello.o -lQtGui -lQtCore -lpthread

成功生成可执行文件

蚁穴虽小,溃之千里。

QtCore: No such file or directory

相关文章:

你感兴趣的文章:

标签云: