Solved Static link: Q_IMPORT_PLUGIN(qico) unresolved external symbol
-
Hello Qt-Community,
I go a unsolved problem. I couln´t find a solution in google or in the forum so I have to ask here.
I want to compile a static version of my program for privat use but I got the following problem:
I see no icons in my application, as a solution I have found "this":http://qt-project.org/forums/viewthread/13367 thread.
So I have added "Q_IMPORT_PLUGIN(qico)" in my main.cpp.
@#include <QApplication>
#include <QtPlugin>Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
Q_IMPORT_PLUGIN(qico)@If I try to compile, I get this error:
@main.obj : error LNK2019: unresolved external symbol ""struct QStaticPlugin const __cdecl qt_static_plugin_qico(void)" (?qt_static_plugin_qico@@YA?BUQStaticPlugin@@XZ)" in function ""public: __thiscall StaticqicoPluginInstance::StaticqicoPluginInstance(void)" (??0StaticqicoPluginInstance@@QAE@XZ)".@My Dev system:
Visual Studio 2012, Windows 7 x64.
Under Linker-> Input I have added "qico.lib" and all other necessary libs as additional dependencies.
Without "Q_IMPORT_PLUGIN(qico)" I can compile my application and it´s works fine. -
Hi and welcome to devnet,
Did you add:
@QTPLUGIN += qico@
to your pro file ?
-
[quote author="SGaist" date="1386002079"]Hi and welcome to devnet,
Did you add:
@QTPLUGIN += qico@
to your pro file ?[/quote]
[/quote]
I have tryed to export the project to a .pro file and using QT Creator but I got other erros. I would like to keep using Visual Studio. Except for this error, I got no other problems with VS compiler.
EDIT:
And I am not if this parameter is the problem becouse "Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)" works great. -
Remove all "Q_IMPORT_PLUGIN" and add
@QTPLUGIN += qico@
to .pro file.EDIT:
From my .pro files:
@CONFIG += c++11 static
INCLUDEPATH += $(QTDIR)\plugins\imageformats
QTPLUGIN += qico@ -
Ok, but how can I use a .pro file? SO far as I know, Visual Studio don´t using the .pro file for compiling the application.
And there are no .pro, .pri or other Qt files in my project folder. -
I suggest you to use Qt Creator for developing but Visual Studio only for compilation. I think Creator is much more better for editing Qt sources.
Qt Creator will make a .pro file for new project. -
Sorry but I am not satisfied with this answer. I have created my Application complete in VS. Until I switched to static version everything has worked correctly. And after switching to static I could import the windows plugin (Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)) without any problems.
There must be a solution to do the same with ico plugin. If is it an issue, it should be reported and fixed.
To switch an IDE each time if something doesn´t woks, it´s not a solution for me. -
Silly question but… Since you built Qt yourself, are you sure that you built the ico image format ?
-
[quote author="SGaist" date="1386279598"]Silly question but… Since you built Qt yourself, are you sure that you built the ico image format ?[/quote]
How can I check it in the build version?
I have never said that I have built Qt by myself. I got it from a friend. It´s version 5.1.2 from the stable git repository. In the plugins/imageformats folder I got qico.lib and qicod.lib. -
[quote author="igromanru" date="1386089950"]Ok, but how can I use a .pro file? SO far as I know, Visual Studio don´t using the .pro file for compiling the application.
And there are no .pro, .pri or other Qt files in my project folder.[/quote]
Then add the qico.lib to the project's "Additional Dependencies" option.
Right click on the project and click Properties. In the "Linker"-Section you can add the qico.lib file and set a "Additional Library Directories". So the Linker can find the symbols. -
[quote author="raven-worx" date="1386317327"]
Then add the qico.lib to the project's "Additional Dependencies" option.
Right click on the project and click Properties. In the "Linker"-Section you can add the qico.lib file and set a "Additional Library Directories". So the Linker can find the symbols.
[/quote]
I got it all the time.
That how it looks like: "JPG":https://www.dropbox.com/s/gf0work3tdci24h/add_dep.JPG (German version)
It´s a screenshot of the debug settings, but the release settings looks similiar. -
and $(QTDIR) points to the correct path? You can check if you click on the "Command Line" entry in the Linker section
-
[quote author="raven-worx" date="1386321519"]and $(QTDIR) points to the correct path? You can check if you click on the "Command Line" entry in the Linker section[/quote]
If $(QTDIR) would be a wrong path, I would have many problems in the whole project. And the windows plugin works too. -
haha...good point... sry for this :)
-
No more ideas?
I think I will try to make a static build by myself. Maybe it will help. -
This works for me:
...
Q_IMPORT_PLUGIN (QICOPlugin)
...I have looked in qicod.lib and have found qt_static_plugin_QICOPlugin function symbol.
-
[quote author="igromanru" date="1386003876"]
"Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)" works great.
[/quote]Which libraries did you link with to get this to work? I'm trying to clear up a small hand full of linker errors with qwindows.lib.
-
[quote author="couragic" date="1390806939"]This works for me:
...
Q_IMPORT_PLUGIN (QICOPlugin)
...I have looked in qicod.lib and have found qt_static_plugin_QICOPlugin function symbol.[/quote]
Thank you very much. This was the solution![quote author="steno" date="1393375998"][quote author="igromanru" date="1386003876"]
"Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)" works great.
[/quote]Which libraries did you link with to get this to work? I'm trying to clear up a small hand full of linker errors with qwindows.lib.[/quote]
Sorry for late answer.
This is all my linked LIBs:
qtmain.lib
Qt5Core.lib
Qt5Gui.lib
Qt5Widgets.lib
qico.lib
ws2_32.lib
sicudt.lib
sicuuc.lib
qminimal.lib
qwindows.lib
opengl32.lib
Qt5PlatformSupport.lib
imm32.lib
winmm.lib -
i got this message from CONFIG+=static
the problem is that StaticqicoPluginInstance is nowhere in the 5.4 package. it has no qico.lib
-
Hi and welcome to devnet,
You won't find this file in a Qt package as they only provide dynamic libraries. If you want a static Qt you'll have to build it yourself. Be aware of the licensing issues that comes with it.