QT编译出现fatal error: QApplication: No such file or directory
2013-10-13 21:29
525 查看
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QLabel *label = new QLabel("hello world");
label->show();
return app.exec();
}
yijun@ubuntu:~/qt/hello$ qmake -project
yijun@ubuntu:~/qt/hello$ qmake hello.pro
运行出错
yijun@ubuntu:~/qt/hello$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../../Qt5.1.1/5.1.1/gcc/mkspecs/linux-g++ -I. -I. -I../../Qt5.1.1/5.1.1/gcc/include -I../../Qt5.1.1/5.1.1/gcc/include/QtGui -I../../Qt5.1.1/5.1.1/gcc/include/QtCore -I.
-o main.o main.cpp
main.cpp:1:24: fatal error: QApplication: No such file or directory
compilation terminated.
yijun@ubuntu:~/qt/hello$
因为Qt5里不再用QtGui模块,而是使用QtWidgets模块,
所以在.pro里加上
在hello.pro文件中添加
QT += core gui widgets
yijun@ubuntu:~/qt/hello$ make
/home/yijun/Qt5.1.1/5.1.1/gcc/bin/qmake -o Makefile hello.pro
g++ -Wl,-O1 -Wl,-rpath,/home/yijun/Qt5.1.1/5.1.1/gcc -Wl,-rpath,/home/yijun/Qt5.1.1/5.1.1/gcc/lib -o hello main.o -L/home/yijun/Qt5.1.1/5.1.1/gcc/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
/usr/bin/ld: cannot find -lGL
collect2: ld returned 1 exit status
make: *** [hello] Error 1
yijun@ubuntu:~/qt/hello$
解决办法:
sudo apt-get install libglu1-mesa-dev -y
装完以后(装的过程比较漫长,而且网速也不给力,装完就重启了ubuntu)
yijun@ubuntu:~/qt/hello$ make
g++ -Wl,-O1 -Wl,-rpath,/home/yijun/Qt5.1.1/5.1.1/gcc -Wl,-rpath,/home/yijun/Qt5.1.1/5.1.1/gcc/lib -o hello main.o -L/home/yijun/Qt5.1.1/5.1.1/gcc/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
yijun@ubuntu:~/qt/hello$
成功
#include <QLabel>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QLabel *label = new QLabel("hello world");
label->show();
return app.exec();
}
yijun@ubuntu:~/qt/hello$ qmake -project
yijun@ubuntu:~/qt/hello$ qmake hello.pro
运行出错
yijun@ubuntu:~/qt/hello$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../../Qt5.1.1/5.1.1/gcc/mkspecs/linux-g++ -I. -I. -I../../Qt5.1.1/5.1.1/gcc/include -I../../Qt5.1.1/5.1.1/gcc/include/QtGui -I../../Qt5.1.1/5.1.1/gcc/include/QtCore -I.
-o main.o main.cpp
main.cpp:1:24: fatal error: QApplication: No such file or directory
compilation terminated.
yijun@ubuntu:~/qt/hello$
因为Qt5里不再用QtGui模块,而是使用QtWidgets模块,
所以在.pro里加上
在hello.pro文件中添加
QT += core gui widgets
yijun@ubuntu:~/qt/hello$ make
/home/yijun/Qt5.1.1/5.1.1/gcc/bin/qmake -o Makefile hello.pro
g++ -Wl,-O1 -Wl,-rpath,/home/yijun/Qt5.1.1/5.1.1/gcc -Wl,-rpath,/home/yijun/Qt5.1.1/5.1.1/gcc/lib -o hello main.o -L/home/yijun/Qt5.1.1/5.1.1/gcc/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
/usr/bin/ld: cannot find -lGL
collect2: ld returned 1 exit status
make: *** [hello] Error 1
yijun@ubuntu:~/qt/hello$
解决办法:
sudo apt-get install libglu1-mesa-dev -y
装完以后(装的过程比较漫长,而且网速也不给力,装完就重启了ubuntu)
yijun@ubuntu:~/qt/hello$ make
g++ -Wl,-O1 -Wl,-rpath,/home/yijun/Qt5.1.1/5.1.1/gcc -Wl,-rpath,/home/yijun/Qt5.1.1/5.1.1/gcc/lib -o hello main.o -L/home/yijun/Qt5.1.1/5.1.1/gcc/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
yijun@ubuntu:~/qt/hello$
成功
相关文章推荐
- Qt5编译时出现<QtGui/QApplication> ---> No such file or directory错误解决办法
- OSX anaconda虚拟环境py27,安装编译MySQLdb出现fatal error: limits.h: No such file or directory
- eclipse编译出现fatal error: gnu/stubs.h: No such file or directory解决方法
- QT5出现问题:QtGui/QApplication: No such file or directory
- QT5.0.1在Windows下 出现QApplication: No such file or directory 问题的解决办法
- QT5.0.1在WIN7下 出现QApplication: No such file or directory 问题的解决办法
- BUG:给Nexus7编译Android4.2的时候出现 fatal error: map: No such file or directory
- QT5.5.0在Windows7(64bit)下 出现QApplication: No such file or directory 问题的解决办法
- Qt 5 在Windows下 出现QApplication: No such file or directory 问题的解决办法
- QT中运行程序时出现错误“ QApplication: No such file or directory"
- Android 源码编译Linux内核时出现fatal error: linux/netfilter/xt_dscp.h: No such file or directory
- QT5.0.1在Windows下 出现QApplication: No such file or directory 问题的解决办法
- QT5.1在Windows下 出现QApplication: No such file or directory 问题的解决办法
- Ubuntu下QT程序中编译时出现speex/speex.h: No such file or directory
- QT5.0.1在Windows下 出现QApplication: No such file or directory 问题的解决办法
- BUG:给Nexus7编译Android4.2的时候出现 fatal error: map: No such file or directory
- QT中编译时出现main.cpp: No such file or directory
- .NET下编译C++代码时出现fatal error C1083: 无法打开包括文件:“xuhk_JNIHelloWorld.h”: No such file or directory错误的解决方法。
- ubuntu 编译是出现 error: openssl/rsa.h: No such file or directory
- 编译Busybox时,出现错误fatal error: curses.h: No such file or directory