[Qbs] Q_INIT_RESOURCE on Windows
Иван Комиссаров
abbapoh at gmail.com
Tue Apr 7 23:33:34 CEST 2020
From the Qt documentation:
"The Q_INIT_RESOURCE() macro is necessary on some platforms for resources stored in a static library.»
This is a workaround to tell the linker not to throw resources away when linking a static library.
It is not required when using a dynamic library as far as I remember.
Ivan
> 7 апр. 2020 г., в 21:26, Alberto Mardegan <mardy at users.sourceforge.net> написал(а):
>
> Hi there!
> I was about to write this to the QtProject mailing list, but then I
> got the doubt that this might be a QBS issue, so I thought of double
> checking with you guys first.
>
> I'm building a GUI application which comes with a shared library which
> contains some Qt resources that need to be made available to the
> application.
>
> However, on windows the build fails, both natively (you can check the
> AppVeyor logs here [1]) and cross-compiled with MXE from Linux. The
> error is:
>
> ==============
> main.cpp.obj : error LNK2019: unresolved external symbol "int __cdecl
> qInitResources_mappero_ui(void)" (?qInitResources_mappero_ui@@YAHXZ)
> referenced in function main
> C:\projects\mappero\default\mappero.a4d1648d\mappero.exe : fatal error
> LNK1120: 1 unresolved externals
> ==============
>
> The main.cpp files contains Q_INIT_RESOURCE(mappero_ui), and a file
>
> release/MapperoUi.e4550a40/qrc_mappero-ui.cpp
>
> is present in the build directory, and it contains (among a lot of other
> stuff) the lines:
>
> ======================
> int QT_RCC_MANGLE_NAMESPACE(qInitResources_mappero_ui)();
> int QT_RCC_MANGLE_NAMESPACE(qInitResources_mappero_ui)()
> {
> int version = 3;
> QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
> (version, qt_resource_struct, qt_resource_name, qt_resource_data);
> return 1;
> }
> ======================
>
> I checked with the nm tool (provided by MXE), and the dll library indeed
> contains the qInitResources_mappero_ui() symbol; however, the symbol is
> not present in the MapperoUi.lib file generated in the same directory.
>
> Shouldn't the symbol in the generated qrc_mappero-ui.cpp file be wrapped
> in a Q_DECL_EXPORT() macro?
>
> Could it be that this is a qbs bug, that for some reason it does not
> invoke rcc with the right options?
>
> Ciao,
> Alberto
>
> [1] https://ci.appveyor.com/project/mardy/mappero/builds/31993601
>
> --
> http://www.mardy.it - Geek in un lingua international
> _______________________________________________
> Qbs mailing list
> Qbs at qt-project.org
> https://lists.qt-project.org/listinfo/qbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20200407/afe216c8/attachment-0001.html>
More information about the Qbs
mailing list