I have plugin and i want static link it with my app. In plugin.pro file i have:
TEMPLATE = lib
CONFIG += staticlib
In plugin.cpp:
Q_EXPORT_PLUGIN2(plugin, pluginClass)
Of course TARGET in .pro file is the same as plugin name.
In myapp.pro file:
LIBS += libplugin.a
main.cpp:
#include <QtGui/QApplication>
#include <QtPlugin>
Q_IMPORT_PLUGIN(plugin)
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
...
return a.exec();
}
Plugin compiles without errors, i got *.a and *.o files, so i copied *.a file to myapp directory and when i trying compile i get error like this:
cannot find -lmyplugin.a
collect2: ld returned 1 exit status
So i gave full path to libplugin.a in myapp.pro file and i got in the line with Q_IMPORT_PLUGIN error:
undefined reference to `qt_plugin_instance_plugin()'
and much errors like this:
undefined reference to `pluginClass::function()'
I included *.h file of my plugin.
What am I doing wrong?
In your plugin .pro file use this code:
CONFIG += plugin static
instead of
CONFIG += staticlib
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With