首页| 论坛| 消息

标题:好心人帮帮我: undefined reference to `qInitResources_findfile()'
作者:ziyi
日期:2009-03-15 17:37
内容:

小妹今天忙了一天就是我为了解决一个问题。。。
我在实践《精通Qt4编程》第三章的3.2节“程序中引入自定义窗口部件”时出现了如下问题:
首先我的主函数是这样的:
#include
#include
#include "ui_findfileform.h"
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QTextCodec::setCodecForTr(QTextCodec::codecForName("gb2312"));
    Q_INIT_RESOURCE(findfile);
    
    QWidget *pWidget = new QWidget;
    Ui::FindFileForm ui;
    ui.setupUi(pWidget);
    pWidget->show();
    
    return app.exec();
}
我的头文件就不粘贴上来了
当我在中断运行qmake -project,qmake,make时,在最后make的时候出现了如下问题:
direct.cpp:(.text+0x76): undefined reference to `qInitResources_findfile()'
上网查过资料,有人说是需要把系统库包含进去,但是我把Q_INIT_RESOURCE(findfile)这一行注释掉的时候,在运行上面的命令就没事,请问如果我想要上面一行,需要怎么解决?等待好心人的回复。。。。


#1 [都市无名者 03-15 23:32]
#include
试试看
#2 [ziyi 03-16 21:47]
谢谢。我试试看。。。
#3 [denton 07-24 23:21]
我的也出现这种问题!!!!
1楼的方法我试了,不行!!
#4 [denton 07-24 23:21]
寻求解决的方法...
#5 [shiroki 07-28 16:57]
你肯定你的工程里有findfile.qrc文件吗? 这个文件加到工程里的吗?
如果你的qrc文件被正确的加入了工程,在编译过程中会生成qrc_findfile.cpp文件, 而qInitResources_findfile()这个函数会在生成的qrc_findfile.cpp里定义。
void Q_INIT_RESOURCE ( name )
Initializes the resources specified by the .qrc file with the specified base name. Normally, Qt resources are loaded automatically at startup. The Q_INIT_RESOURCE() macro is necessary on some platforms for resources stored in a static library.
For example, if your application's resources are listed in a file called myapp.qrc, you can ensure that the resources are initialized at startup by adding this line to your main() function:
Q_INIT_RESOURCE(myapp);

<< 1 2 >> (1/2)

回复 发表
主题 版块