Results 1 to 6 of 6

Thread: Error building chart model/view example

  1. #1
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Error building chart model/view example

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error building chart model/view example

    Are you sure that you link qrc_chart.obj with your program?

  3. #3
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Error building chart model/view example

    Quote Originally Posted by jacek
    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

  4. #4
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Error building chart model/view example

    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

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error building chart model/view example

    Maybe you have to use the -name parameter?

  6. The following user says thank you to jacek for this useful post:

    brcain (25th August 2006)

  7. #6
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Error building chart model/view example

    Quote Originally Posted by jacek
    Maybe you have to use the -name parameter?
    Yes indeed. Thank you. I don't remember reading about that.

    Here's the correct command:
    rcc.exe chart.qrc -name chart -o qrc_chart.cpp

Similar Threads

  1. Drag & drop with model/view (Qt4)
    By yogeshm02 in forum Qt Programming
    Replies: 16
    Last Post: 19th September 2011, 20:36
  2. MODEL/VIEW programming
    By mira in forum Newbie
    Replies: 3
    Last Post: 21st April 2006, 11:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.