当前位置:编程学习 > wap >>

QT编译HELLOWORLD失败

我按网上方法,在WINDOWS安装了DEV-C++5 + QT 4.6.2
详细见:http://www.cnblogs.com/phinecos/archive/2007/04/30/733269.html
在DEV-C++编译运行HELLOWORLD都没问题,在QT Command prompt操作步骤如下:
1。qmake -project
2. qmake
3. mingw32-make
1,2步都没问题,问题出在第三步,报错如图:

[img=http://user.qzone.qq.com/106266469/photo/750ff7a3-9025-443c-b13e-a4476e476b22/][/img]

另附HELLOWORLD代码:
#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();
}


我个人感觉报的错好像与配置或安装的有关,但我重新重了N次,也配了N次,都不行。

--------------------编程问答-------------------- 报错如下:

--------------------编程问答-------------------- 图片还是传不了,如下链接:
http://hi.baidu.com/fsafkjaslfkjsk/album/item/1bec0c2732c983098644f913.html --------------------编程问答-------------------- 图片看不到..

把错误贴上来好了 --------------------编程问答-------------------- D:\hello>mingw32-make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `D:/hello'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\qt
\include\QtCore" -I"..\qt\include\QtGui" -I"..\qt\include" -I"." -I"..\qt\includ
e\ActiveQt" -I"debug" -I"..\qt\mkspecs\win32-g++" -o debug\hello.o hello.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -mthreads -Wl -Wl,-subsystem,windows -o debug\hello.exe debug/hello.o  -L"d:\
qt\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
d:\qt\lib/libqtmaind.a(qtmain_win.o)(.text+0x64):../../include/QtCore/../../src/
corelib/tools/qvector.h:410: undefined reference to `_Unwind_Resume'
d:\qt\lib/libqtmaind.a(qtmain_win.o)(.text+0x12a):C:\iwmake\build_mingw_opensour
ce\src\winmain/qtmain_win.cpp:135: undefined reference to `_Unwind_Resume'
d:\qt\lib/libqtmaind.a(qtmain_win.o)(.text$_ZN7QVectorIPcE7reallocEii[QVector<ch
ar*>::realloc(int, int)]+0x1a1):../../include/QtCore/../../src/corelib/tools/qve
ctor.h:482: undefined reference to `_Unwind_Resume'
d:\qt\lib/libqtmaind.a(qtmain_win.o)(.text$_ZN7QVectorIPcE7reallocEii[QVector<ch
ar*>::realloc(int, int)]+0x1dc):../../include/QtCore/../../src/corelib/tools/qve
ctor.h:483: undefined reference to `_Unwind_Resume'
d:\qt\lib/libqtmaind.a(qtmain_win.o)(.eh_frame+0x12): In function `Z4qMinIiERKT_
S2_S2_':
../../include/QtCore/../../src/corelib/thread/qbasicatomic.h:95: undefined refer
ence to `__gxx_personality_v0'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\hello.exe] Error 1
mingw32-make[1]: Leaving directory `D:/hello'
mingw32-make: *** [debug] Error 2 --------------------编程问答-------------------- 不解。。太怪了点 --------------------编程问答-------------------- mingw 的lib没有添加到-L选项中去 --------------------编程问答-------------------- http://get.qt.nokia.com/qtsdk/qt-sdk-win-opensource-2010.02.1.exe 这是下载链接 直接迅雷下载
默认安装 用自带的IDE编译HelloWorld 肯定行 --------------------编程问答-------------------- 应该是你环境么有配好引起的~~~ --------------------编程问答-------------------- 根据6#的提示,在网上找了找,在makefile.debug中FLAGS后添加-Wl,-Bdynamic -lgcc_s.提示:
 cannot find -lgcc_s 
根据8#所说,我的环境变量配置如下:
Setting up a MinGW/Qt only environment...
-- QTDIR set to D:\qt
-- PATH set to D:\qt\bin
-- Adding D:\DEV-CPP\bin to PATH
-- Adding C:\WINDOWS\System32 to PATH
-- QMAKESPEC set to win32-g++
--------------------编程问答-------------------- 经常会出先各种问题 make clean一下,再重新编译下试试 --------------------编程问答-------------------- 我按照10#的指示,make clean后再编译,问题依旧。我想重装都不行,重新编译成功可能性很小吧。 --------------------编程问答-------------------- 昨天我第一次装这个也好像报这个错误了!弄了我一下午加一晚上,重装了3次,还换了机子实验,总算成功了!反正如果装得正确的话应该是不必要配什么环境的!注意看看你的安装目录,文件保存目录有没有中文字符把!我昨天就是由于路径中有中文字符就出错了!不过现在happy了! --------------------编程问答-------------------- 我注意到中文的这些问题了。
我的DEV-C++是在D:\DEV-CPP下,QT装的是D:\QT,mingw安的也是D:\DEV-CPP。
实在没办法,我只能换换机子试试看了。 --------------------编程问答-------------------- 我在另一台机子上试了一下,问题一样。现在有点崩溃了。 --------------------编程问答-------------------- 把 D:\DEV-CPP\bin 换成单独的 mingw32?或者直接用SDK试试 --------------------编程问答--------------------

我也有一样的问题同问 --------------------编程问答-------------------- 我得结贴了,但问题依旧啊! --------------------编程问答-------------------- Qt Creator 下是没问题的 --------------------编程问答-------------------- 我卸载了qt-win-opensource-4.6.2-mingw.exe
安装了qt-sdk-win-opensource-2010.02.1.exe

编译运行都没问题了。以后就用QT Creator了。
补充:移动开发 ,  Qt
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,