QtCore: No such file or directory

本文解决在Fedora10系统中使用QT4编译器时遇到的问题,通过安装和配置QT4编译器,解决找不到相关头文件的错误,并成功生成可执行文件。

系统环境:Fedora10

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

hello.h:4:17: error: QtCore: No such file or directory
hello.h:5:16: error: QtGui: No such file or directory
hello.h:12:23: error: QPixmapCache: No such file or directory
hello.h:13:18: error: QThread: No such file or directory
make: *** [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.cpp
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 moc_hello.o moc_hello.cpp
g++  -o hello main.o moc_hello.o     -lQtGui -lQtCore -lpthread


成功生成可执行文件


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

WangLanguager

您的鼓励是对我最大的支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值