This is weird. I don't see the problem. QMake should find it automatically.
This is weird. I don't see the problem. QMake should find it automatically.
Qt Code:
$ ls Makefile myplugin.cpp myplugin.h myplugin.pro $ cat myplugin.pro ###################################################################### # Automatically generated by qmake (2.01a) Fri Aug 27 08:29:32 2010 ###################################################################### QT += gui TEMPLATE = lib CONFIG = plugin TARGET = $$qtLibraryTarget(myplugin) DEPENDPATH += . INCLUDEPATH += . # Input HEADERS += myplugin.h SOURCES += myplugin.cpp $ qmake $ make g++ -c -m64 -pipe -march=x86-64 -mtune=generic -O2 -pipe -fPIC -I/usr/share/qt/mkspecs/linux-g++-64 -I. -I. -o myplugin.o myplugin.cpp In file included from myplugin.cpp:1:0: myplugin.h:1:17: fatal error: QtGui: No such file or directory compilation terminated. make: *** [myplugin.o] Error 1To copy to clipboard, switch view to plain text mode
As you can see in the following line:
Qt Code:
g++ -c -m64 -pipe -march=x86-64 -mtune=generic -O2 -pipe -fPIC -I/usr/share/qt/mkspecs/linux-g++-64 -I. -I. -o myplugin.o myplugin.cppTo copy to clipboard, switch view to plain text mode
The following include paths are at least missing:
These are pseudo paths, I don't know where they are on your system.Qt Code:
-I/usr/include/.../QtCore -I/usr/include/.../QtGuiTo copy to clipboard, switch view to plain text mode
This is mighty strange as, like I said, when QT += gui and QT += core (which are default, you don't generally have to add those manually to the .pro file) are added to your .pro file, the include paths should be set by qmake.
One thing I can think of is to manually delete the Makefile, and try qmake and make again. But I guess this won't solve it either.
Edit: try this too:
Note the +
When you do not add the +, you erase all the configs
Another error:
$ make
/usr/bin/qmake -unix -o Makefile myplugin.pro
g++ -c -m64 -pipe -march=x86-64 -mtune=generic -O2 -pipe -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt/mkspecs/linux-g++-64 -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I. -o myplugin.o myplugin.cpp
myplugin.cpp: In function ‘QObject* qt_plugin_instance()’:
myplugin.cpp:18:1: error: cannot allocate an object of abstract type ‘MyPlugin’
myplugin.h:6:1: note: because the following virtual functions are pure within ‘MyPlugin’:
/home/michael/junk/QPanel/qpanelappletinterface.h:13:18: note: virtual void QPanelAppletInterface::showSettingsDialog()
make: *** [myplugin.o] Error 1
The interface:
Qt Code:
#ifndef QPANELAPPLETINTERFACE_H #define QPANELAPPLETINTERFACE_H #include <QtPlugin> class QPanelAppletInterface { public: virtual ~QPanelAppletInterface() {} virtual void showSettingsDialog() = 0; }; Q_DECLARE_INTERFACE(QPanelAppletInterface, "com.trolltech.PlugAndPaint.QPanelAppletInterface/1.0") #endif // QPANELAPPLETINTERFACE_HTo copy to clipboard, switch view to plain text mode
Yes, you need to add the void showSettingsDialog() function to MyPlugin
My main application now "unexpectedly finishes" if I uncomment the commented out line:
Qt Code:
dirIter.next(); QPanelAppletInterface *plugin = qobject_cast<QPanelAppletInterface*>(loader.instance()); //ui->appletLayout->addWidget(plugin->getWidget());To copy to clipboard, switch view to plain text mode
Most probably, plugin is 0 resulting in the crash.
To prevent the crash, but not solve it do this:
Qt Code:
if (plugin) ui->appletLayout->addWidget(plugin->getWidget());To copy to clipboard, switch view to plain text mode
Now, to solve the plugin problem.
1. check if loader does point to the correct file. This means that dirIter.filePath() should be the same as "/home/you/where/the/plugin/is/myplugin.so"
2. Check if the cast can actually be performed. Therefor, the instance returned by the plugin loader needs to be correct at least.
It finally works!!!
The problem is that it was trying to load the files "." and "..".
Nice, well done.
Bookmarks