QT5.0.1在Windows下 出现QApplication: No such file or directory 问题的解决办法

本文介绍了如何在Windows7环境下安装Qt5.0.1,并通过实例演示了创建和调试一个简单的Qt HelloWorld程序的过程及遇到的问题与解决办法。
      最近在Windows7下安装了最新的Qt5.0.1的Windows安装包, 可以到QT官网http://qt-project.org/downloads,该版本集成了Qt5.0.1库、MinGW4.7编译器、Qt Creator 2.6.2,解决了以前Qt 在Windows下单独安装的问题,不用再像以前的版本一样分别安装三个软件了。下载后默认安装就OK了,不过安装后居然有3.68G的文件,比VS2012多不少。

测试一下HelloWorld程序,首先在Qt Creator中打开菜单【文件】->【新建文件或项目】(或直接Ctrl+N),选择【其他项目】->【空的QT项目】,取名为HelloWorld,然后再往工程里面添加一个HelloWorld.cpp的C++源文件。
HelloWorld.cpp代码如下:
 
#include <QApplication>
#include <QPushButton>
#include <QLabel>
#include <QHBoxLayout>


int main(int argc, char **argv)

{

    QApplication app(argc, argv);



    QWidget *pMainWidget = new QWidget;

    QHBoxLayout *pBoxLayout = new QHBoxLayout;



    QLabel *pLabel = new QLabel(pMainWidget);

    pLabel->setText("Hello World!");



    QPushButton *pQuitButton = new QPushButton(pMainWidget);

    pQuitButton->setText("Quit Qt!");



    pBoxLayout->addWidget(pLabel);

    pBoxLayout->addWidget(pQuitButton);



    QSize windowSize(300,200);

    pMainWidget->resize(windowSize);

    pMainWidget->show();



    QObject::connect(pQuitButton,SIGNAL(clicked()),pMainWidget,SLOT(close()));



    return app.exec();



}

运行之后出现以下错误:QApplication: No such file or directory,估计是相应的QApplication对应的库文件找不到。
上网查了一大通,基本都是Linux ubuntu等版本下的解决方案,如下csdn博客:http://blog.csdn.net/apple1985507/article/details/5435358;找了半天在这篇新浪博客找到了答案:
http://blog.sina.com.cn/s/blog_9da24f3b0101epan.html
解决方法是:在HelloWorld.pro工程项目文件中添加一行QT += widgets,然后再编译运行就OK了。

 

*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'D:\keil5\ARM\ARMCC\Bin' Build target 'Target 1' assembling startup_stm32f40_41xxx.s... compiling stm32f4xx_cryp_tdes.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_cryp_tdes.c: 0 warnings, 1 error compiling stm32f4xx_can.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_can.c: 0 warnings, 1 error compiling stm32f4xx_cryp.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_cryp.c: 0 warnings, 1 error compiling stm32f4xx_adc.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_adc.c: 0 warnings, 1 error compiling stm32f4xx_cryp_des.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_cryp_des.c: 0 warnings, 1 error compiling stm32f4xx_cec.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_cec.c: 0 warnings, 1 error compiling stm32f4xx_dac.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_dac.c: 0 warnings, 1 error compiling stm32f4xx_dfsdm.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_dfsdm.c: 0 warnings, 1 error compiling stm32f4xx_crc.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_crc.c: 0 warnings, 1 error compiling system_stm32f4xx.c... start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ start\system_stm32f4xx.c: 0 warnings, 1 error compiling stm32f4xx_cryp_aes.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_cryp_aes.c: 0 warnings, 1 error compiling stm32f4xx_dcmi.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_dcmi.c: 0 warnings, 1 error compiling stm32f4xx_dma.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_dma.c: 0 warnings, 1 error compiling stm32f4xx_dbgmcu.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_dbgmcu.c: 0 warnings, 1 error compiling misc.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\misc.c: 0 warnings, 1 error compiling stm32f4xx_dma2d.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_dma2d.c: 0 warnings, 1 error compiling stm32f4xx_dsi.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_dsi.c: 0 warnings, 1 error compiling stm32f4xx_exti.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_exti.c: 0 warnings, 1 error compiling stm32f4xx_flash.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_flash.c: 0 warnings, 1 error compiling stm32f4xx_flash_ramfunc.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_flash_ramfunc.c: 0 warnings, 1 error compiling stm32f4xx_fmc.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_fmc.c: 0 warnings, 1 error compiling stm32f4xx_fmpi2c.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_fmpi2c.c: 0 warnings, 1 error compiling stm32f4xx_fsmc.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_fsmc.c: 0 warnings, 1 error compiling stm32f4xx_gpio.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_gpio.c: 0 warnings, 1 error compiling stm32f4xx_hash.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_hash.c: 0 warnings, 1 error compiling stm32f4xx_hash_sha1.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_hash_sha1.c: 0 warnings, 1 error compiling stm32f4xx_hash_md5.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_hash_md5.c: 0 warnings, 1 error compiling stm32f4xx_i2c.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_i2c.c: 0 warnings, 1 error compiling stm32f4xx_iwdg.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_iwdg.c: 0 warnings, 1 error compiling stm32f4xx_lptim.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_lptim.c: 0 warnings, 1 error compiling stm32f4xx_ltdc.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_ltdc.c: 0 warnings, 1 error compiling stm32f4xx_pwr.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_pwr.c: 0 warnings, 1 error compiling stm32f4xx_qspi.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_qspi.c: 0 warnings, 1 error compiling stm32f4xx_rcc.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_rcc.c: 0 warnings, 1 error compiling stm32f4xx_rng.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_rng.c: 0 warnings, 1 error compiling stm32f4xx_rtc.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_rtc.c: 0 warnings, 1 error compiling stm32f4xx_sdio.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_sdio.c: 0 warnings, 1 error compiling stm32f4xx_spdifrx.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_spdifrx.c: 0 warnings, 1 error compiling stm32f4xx_spi.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_spi.c: 0 warnings, 1 error compiling stm32f4xx_sai.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_sai.c: 0 warnings, 1 error compiling stm32f4xx_syscfg.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_syscfg.c: 0 warnings, 1 error compiling stm32f4xx_tim.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_tim.c: 0 warnings, 1 error compiling stm32f4xx_usart.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_usart.c: 0 warnings, 1 error compiling stm32f4xx_wwdg.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ libraries\stm32f4xx_wwdg.c: 0 warnings, 1 error compiling main.c... .\start\core_cm4.h(188): error: #5: cannot open source input file "core_cmInstr.h": No such file or directory #include <core_cmInstr.h> /* Core Instruction Access */ user\main.c: 0 warnings, 1 error compiling stm32f4xx_it.c... user\stm32f4xx_it.h(30): error: #5: cannot open source input file "main.h": No such file or directory #include "main.h" user\stm32f4xx_it.c: 0 warnings, 1 error ".\Objects\MJ.axf" - 46 Error(s), 0 Warning(s). Target not created.这里报错是什么意思,为什么,怎么解决
最新发布
08-28
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值