PDA

View Full Version : Error building chart model/view example



brcain
25th August 2006, 19:07
Hello,

I'm trying to understand how to use the Qt 4 model/view architecture. I've gone through the examples in the book. Now I'm looking at the Qt installation examples.

I've encountered a link error while trying to build the following example:

...\examples\itemviews\chart

It's due to an unresolved link to (in main.cpp:30):

Q_INIT_RESOURCE(chart);

Specifically, the error is:

1>main.obj : error LNK2019: unresolved external symbol "int __cdecl qInitResources_chart(void)" (?qInitResources_chart@@YAHXZ) referenced in function _main
1>C:\cainbr\qt\mvc\chart\Debug\chart.exe : fatal error LNK1120: 1 unresolved externals

Note I did generate the resource object code and added it to the project:

rcc chart.qrc -o qrc_chart.cpp

Note that I'm using:

VC++ 2005, v2.0.50727
Qt 4.1.4 open-source edition
Qt 4.1.4 patch for VC++ 2005 from SourceForge

Thanks,
Ben

jacek
25th August 2006, 19:12
Are you sure that you link qrc_chart.obj with your program?

brcain
25th August 2006, 19:25
Are you sure that you link qrc_chart.obj with your program?
I did add qrc_chart.cpp to my project's Source files listing. And I see that qrc_chart.obj was generated. And there are references to it when I turn verbosity on for linking. I'm not an expert concerning what happens behind the scenes with VC++. But, I think it should be finding it.


1> Found "bool __cdecl qRegisterResourceData(int,unsigned char const *,unsigned char const *,unsigned char const *)" (?qRegisterResourceData@@YA_NHPBE00@Z)
1> Referenced in qrc_chart.obj
...
1> Found "bool __cdecl qUnregisterResourceData(int,unsigned char const *,unsigned char const *,unsigned char const *)" (?qUnregisterResourceData@@YA_NHPBE00@Z)
1> Referenced in qrc_chart.obj
...
1> Found __RTC_CheckEsp
1> Referenced in qrc_chart.obj
...
1> Found __RTC_Shutdown
1> Referenced in qrc_chart.obj
...
1> Found _atexit
1> Referenced in qrc_chart.obj

brcain
25th August 2006, 19:32
I found the link error. But, I'm not sure why it happened. It looks like when I ran rcc.exe it didn't generate the right routine name.

It generated:

int qInitResources()
But, it should have generated:

int qInitResources_chart()

Any ideas why? I used the chart.qrc file "as is" from the distribution. Did I execute the command correctly?

rcc.exe chart.qrc -o qrc_chart.cpp

jacek
25th August 2006, 23:00
Maybe you have to use the -name parameter?

brcain
25th August 2006, 23:37
Maybe you have to use the -name parameter?

Yes indeed. Thank you. I don't remember reading about that. :o

Here's the correct command:

rcc.exe chart.qrc -name chart -o qrc_chart.cpp