Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.7.1
-
None
-
Windows 7
Description
The documentation (http://doc.qt.io/qt-5/resources.html and https://wiki.qt.io/QtResources) suggests to call Q_INIT_RESOURCE(name) from main to trigger loading of library resources. This works fine for static libraries. For shared libraries however, it generates a linker error (unresolved external symbol).
I have spent a few hours trying to figure out why and I think the reason must be that the generated qInitResources_name() is not exported, i.e. it is not declared using Q_DECL_EXPORT. Therefore it cannot be seen from the application's main function.
If I am right, I suggest that you mention this in the documentation, or even better; modifies the Q_INIT_RESOURCE macro to ensure that the generated function gets exported when generated inside a shared library.
For now, the obvious workaround is to create a separate function in the shared library that uses Q_INIT_RESOURCE, make sure to export this function using Q_DECL_EXPORT and call it from main instead of using Q_INIT_RESOURCE directly.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-59394 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
365354,14 | Rewrite Qt Resource System overview | dev | qt/qtbase | Status: MERGED | +2 | 0 |
371331,2 | Rewrite Qt Resource System overview | 6.2.0 | qt/qtbase | Status: MERGED | +2 | 0 |
371332,2 | Rewrite Qt Resource System overview | 6.2 | qt/qtbase | Status: MERGED | +2 | 0 |