• 7743阅读
  • 0回复

不好意思 新手入门 VS2008和QT4.5编译Hello小程序, Debug可以 Release链接失败 [复制链接]

上一主题 下一主题
离线hushui
 

只看楼主 倒序阅读 楼主  发表于: 2009-03-21
Debug编译运行都没有问题 ,relase版本编译链接出错


1>------ Build started: Project: HelloQtWindows, Configuration: Release Win32 ------
1>Rcc'ing helloqtwindows.qrc...
1>C:\Qt\4.5.0\bin\rcc.exe -name "helloqtwindows" -no-compress ".\helloqtwindows.qrc" -o .\GeneratedFiles\qrc_helloqtwindows.cpp
1>Linking...
1>qtmain.lib(qtmain_win.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
1>helloqtwindows.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall HelloQtWindows::metaObject(void)const " (?metaObject@HelloQtWindows@@UBEPBUQMetaObject@@XZ)
1>helloqtwindows.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall HelloQtWindows::qt_metacast(char const *)" (?qt_metacast@HelloQtWindows@@UAEPAXPBD@Z)
1>helloqtwindows.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall HelloQtWindows::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@HelloQtWindows@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
1>helloqtwindows.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const HelloQtWindows::staticMetaObject" (?staticMetaObject@HelloQtWindows@@2UQMetaObject@@B)
1>D:\Develop\GUI\QT\Example\HelloQtWindows\Release\HelloQtWindows.exe : fatal error LNK1120: 4 unresolved externals
1>Build log was saved at "file://d:\Develop\GUI\QT\Example\HelloQtWindows\Release\BuildLog.htm"
1>HelloQtWindows - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


这个简单的类 头文件如下

#ifndef HELLOQTWINDOWS_H
#define HELLOQTWINDOWS_H

#include <QtGui/QMainWindow>
#include "ui_helloqtwindows.h"

class HelloQtWindows : public QMainWindow
{
    Q_OBJECT

public:
    HelloQtWindows(QWidget *parent = 0, Qt::WFlags flags = 0);
    ~HelloQtWindows();

private:
    Ui::HelloQtWindowsClass ui;

private slots:
    void on_checkBox_stateChanged(int);
    void on_listView_clicked(const QModelIndex &);
};

#endif // HELLOQTWINDOWS_H


实现文件

#include <QMessageBox>
#include <QTranslator>

#include "helloqtwindows.h"

HelloQtWindows::HelloQtWindows(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    ui.setupUi(this);
}

HelloQtWindows::~HelloQtWindows()
{

}


void HelloQtWindows::on_listView_clicked(const QModelIndex &)
{
    
}

void HelloQtWindows::on_checkBox_stateChanged(int state)
{
    if (Qt::Checked == state)
    {
        QMessageBox::information(this, tr("Test Title"), tr("Checked me!"));
        ui.calendarWidget->setEnabled(false);
    }
    else
    {
        QMessageBox::information(this, tr("Test Title"), tr("Unchecked me!"));
        ui.calendarWidget->setEnabled(true);
    }
}


不知道这个链接错误 与环境设定有关系吗?
为什么Debug可以
我已经详细比较了 2个设定 似乎没有什么问题。
另外我的环境编译了其他网上的例子程序 比较复杂的QT图形程序 Debug和Release都是OK的
请教高手啊   项目文件 HelloQtWindows.zip (14 K) 下载次数:13
完整的项目见附件  谢谢 项目文件 HelloQtWindows.zip (14 K) 下载次数:13
快速回复
限100 字节
 
上一个 下一个