[Qt-interest] Linux shared library can not load Qt resources?Resource initialization problem ?

Jaco Naude naude.jaco at gmail.com
Wed Dec 1 14:55:37 CET 2010


No problem. It took a while to figure out yes.

Glad it worked,
Cheers
Jaco

On Wed, Dec 1, 2010 at 1:23 PM, Ed Sutton <ESutton at fescorp.com> wrote:

> Hi Jaco,
>
> Thank you very much for providing the solution to my problem.
>
> >I've run into funny problems before on Ubuntu where you have multiple
> libraries with resource files with the same names. For example, if you have
> two libraries both called "resources.qrc" only one of the will be loaded.
> Also, if 0>you have a "resources.qrc" file in your application and a
> "resources.qrc" file in a shared library, only one of them will be loaded. I
> could not figure out which one but it seemed like it depended on the order
> that its loaded. Thus >I've started to give my resource files the same names
> are the libraries where they belong and from there on it just works.
>
> >Note that it was only a problem on Ubuntu, not on Windows.
>
> It turns out using the same name for the Qt resource file for both the
> shared library and the application is a problem on Red Hat Enterprise Linux
> 5.x as well.  I renamed it and all is good now!
>
> Thanks you so much!  I would have *never* figured this one out.
>
> Thanks again,
>
> -Ed
>
>
>
>
> Hope it helps,
> Cheers
> Jaco
>
> On Tue, Nov 30, 2010 at 11:03 PM, Ed Sutton <ESutton at fescorp.com<mailto:
> ESutton at fescorp.com>> wrote:
>
> On Nov 30, 2010, at 4:19 PM, Scott Aron Bloom wrote:
>
> > Please don't respond to my email.. Reply to the list...
> >
> > Yes, however, I usually call it for all my DLLs that contain resources
> > from the main.cpp or after they are loaded via a QLibrary::load
>
>
> Curious.  Still no success.
>
> I bypassed the Q_INIT_RESOURCES macro and added this to the constructor of
> the shared library class that access the resource.
>
> SharedLibClass:: SharedLibClass()
> {
>  // I think Q_INIT_RESOURCE basically exapnds to this:
>  // resource file is named resources.qrc.
>  extern int qInitResources_resources();
>  qInitResources_resources();
> }
>
> >
> > Scott
> >
> > -----Original Message-----
> > From: Ed Sutton [mailto:ESutton at fescorp.com<mailto:ESutton at fescorp.com>]
> > Sent: Tuesday, November 30, 2010 2:17 PM
> > To: Scott Aron Bloom
> > Subject: Re: [Qt-interest] Linux shared library can not load Qt
> > resources?Resource initialization problem ?
> >
> >
> >> Are you calling Q_INIT_RESOURCES ??
> >
> > My resource file is named resources.qrc.  I added
> > Q_INIT_RESOURCE(resources) to a class constructor in the shared library
> > that the client creates an instance of.  The resource is used internally
> > by the library and not accessed directly.  Calling it there did not
> > help.  Is this what you meant?
> >
> > Than you for your help,
> >
> > -Ed
> >
> >
> >
> >
> >
> >>
> >> Scott
> >>
> >> -----Original Message-----
> >> From: qt-interest-bounces at trolltech.com<mailto:
> qt-interest-bounces at trolltech.com>
> >> [mailto:qt-interest-bounces at trolltech.com<mailto:
> qt-interest-bounces at trolltech.com>] On Behalf Of Ed Sutton
> >> Sent: Tuesday, November 30, 2010 2:06 PM
> >> To: Qt-interest Interest
> >> Subject: [Qt-interest] Linux shared library can not load Qt resources?
> >> Resource initialization problem ?
> >>
> >> I added a Qt resource file to my shared library project.  I added a
> >> "/resource" prefix then added an XSL file to the resource.  I can not
> >> figure out how to load the resource.  I found some postings about
> >> problems with Qt resources in libraries but did not understand or find
> > a
> >> solution that worked.  Has anyone seen this?
> >>
> >> QString resourcePath = ":/resource/files/eot.xsl";
> >> if( false == QFile::exists(resourcePath)
> >> {
> >>  printf("*** Error - Resource path not found : \"%s\"\n",
> >> resourcePath.toLatin1().data());
> >> }
> >> else
> >> {
> >>  QFile::copy(resourcePath, styleSheetPathFileName))
> >> }
> >>
> >>
> >> // File: resources.qrc
> >>
> >> <RCC>
> >>   <qresource prefix="/resource">
> >>       <file>files/eot.xsl</file>
> >>   </qresource>
> >> </RCC>
> >>
> >> Thanks in advance,
> >>
> >> -Ed
> >>
> >>
> >> _______________________________________________
> >> Qt-interest mailing list
> >> Qt-interest at trolltech.com<mailto:Qt-interest at trolltech.com>
> >> http://lists.trolltech.com/mailman/listinfo/qt-interest
> >>
> >> _______________________________________________
> >> Qt-interest mailing list
> >> Qt-interest at trolltech.com<mailto:Qt-interest at trolltech.com>
> >> http://lists.trolltech.com/mailman/listinfo/qt-interest
> >
> >
> > -Ed
> >
> >
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com<mailto:Qt-interest at trolltech.com>
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
> -Ed
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com<mailto:Qt-interest at trolltech.com>
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
> -Ed
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101201/96ba5fc3/attachment.html 


More information about the Qt-interest-old mailing list