QT中运行程序时出现错误“ QApplication: No such file or directory"
2014-12-22 13:19
477 查看
在根目录下创建 一个文件夹,名称为hello,在该文件夹下创建一个hello.cpp文件,内容如下:
在该文件下运行以下命令:
qmake -project
该命令生成一个hello.pro工程文件
qmake
该命令生成一个Makefile文件
make
该命令用来生成目标文件:hello,hello.o文件
不过在此过程中遇到一个错误:
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o hello.o hello.cpp
hello.cpp:1:24: fatal error: QApplication: No such file or directory
#include <QApplication>
^
compilation terminated.
make: *** [hello.o] Error 1
原因:没有安装QT4的开发包
解决方案:
把开发包装上,在Ubuntu下使用如下命令:sudo apt-get install libqt4-dev
此时再运行make命令即可生成hello,hello.o文件,
在该目录下运行./hello命令,即可运行生成的程序。
#include <QApplication> #include <QLabel> int main(int argc, char **argv) { QApplication a(argc, argv); QLabel mylabel("Hello the World"); mylabel.show(); return a.exec(); }
在该文件下运行以下命令:
qmake -project
该命令生成一个hello.pro工程文件
qmake
该命令生成一个Makefile文件
make
该命令用来生成目标文件:hello,hello.o文件
不过在此过程中遇到一个错误:
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o hello.o hello.cpp
hello.cpp:1:24: fatal error: QApplication: No such file or directory
#include <QApplication>
^
compilation terminated.
make: *** [hello.o] Error 1
原因:没有安装QT4的开发包
解决方案:
把开发包装上,在Ubuntu下使用如下命令:sudo apt-get install libqt4-dev
此时再运行make命令即可生成hello,hello.o文件,
在该目录下运行./hello命令,即可运行生成的程序。
相关文章推荐
- 运行linux的脚本老是出现": No such file or directory"错误
- Qt5编译时出现<QtGui/QApplication> ---> No such file or directory错误解决办法
- SlickEdit在64bit Ubuntu下运行vsinst安装程序出现"No such file or directory"的解决方法
- 解决 #include "QtGui/QApplication" No such file or directory
- QT编译出现fatal error: QApplication: No such file or directory
- 错误 'Cannot run program "/home/uv/IDE/adt/sdk/platform-tools/adb": error=2, No such file or directory
- FastDFS安装配置过程中出现错误提示"/home/yuqing/fastdfs" can't be accessed, error info: No such file or directory
- VC编译程序时Cannot open precompiled header file: 'Debug/.pch': No such file or directory错误处理
- Ubuntu下QT程序中编译时出现speex/speex.h: No such file or directory
- CodeBlocks "no such file or directory"错误解决
- QT5.0.1在Windows下 出现QApplication: No such file or directory 问题的解决办法
- QT5出现问题:QtGui/QApplication: No such file or directory
- QT5.5.0在Windows7(64bit)下 出现QApplication: No such file or directory 问题的解决办法
- QT5.0.1在WIN7下 出现QApplication: No such file or directory 问题的解决办法
- QT关于“fatal error: QApplication: No such file or directory“错误解决
- QT5.1在Windows下 出现QApplication: No such file or directory 问题的解决办法
- Cygwin中用NDK来编译程序出现"No such file or directory"问题
- Ubuntu16.0.4LTS 64位上运行32位程序,提示No such file or directory?错误的解决办法
- Qt4项目迁移Qt5项目一问题解决方法:#include <QtGui/QApplication> ---> No such file or directory
- Ubuntu16.0.4LTS 64位上运行32位程序,提示No such file or directory?错误的解决办法