Spamdark
Spamdark

Reputation: 1391

Shared Library QT Resource

Im having again another problem. This time, I have a .dll, a shared library that contains a .qrc (QT Resource) file, the problem is, that when I'm trying to access one of the resources of the library, it doesn't work. I tried implementing the:

Q_INIT_RESOURCE(resourcefilename)

and it stills not working. (It says that the "qInitResources_resourcefilename()" is not found.)

Upvotes: 6

Views: 1651

Answers (2)

eatyourgreens
eatyourgreens

Reputation: 1103

I am going to assume that you are using Windows because you say you have a .dll

I just ran into this same problem that the function qInitResources_resourcefilename cannot be found. This function does indeed exist in the shared library if your library has a .qrc file (check the mapfile). The problem is that this function is not exported and so the linker does not find it while linking the main App. I added the function qInitResources_resourcefilename to the export table of the shared library as follows.

Add a new file to the shared library export.def

LIBRARY
EXPORTS
  qInitResources_resourcefilename

Add the following to your shared library .pro file

QMAKE_LFLAGS += /DEF:\"$${PWD}\\export.def\"
OTHER_FILES += \
    export.def

Your solution works around this problem because RmiLib::startResources is included in the export table.

I am using Windows 7, MSVC 2010, Qt 5.2.0

Upvotes: 3

Spamdark
Spamdark

Reputation: 1391

Nevermind. I found the solution. The qInitResources_name() was not found. So, I created a function inside the shared library

int RmiLib::startResources(){
    extern int qInitResources_rmi();
    return qInitResources_rmi();
}

Then, on the main App, I called that function, and yay! It worked.

Upvotes: 4

Related Questions