PDA

View Full Version : Plugins HowTo?



Royceybaby
17th October 2006, 18:01
I hope someone can help me, I am trying to learn how to develop a simple plugin system.

I am running Qt4.1.4 compiled with MingW on Windows XP.

I have tried following the Qt documentation and some of the threads on this forum but cannot get it working.

I have attached my code, don't laugh :), so maybe some of you wise people can help.

Thanks,
Royce

jacek
17th October 2006, 19:43
You must compile both the plugin and application in the same mode, so you have to add "CONFIG += release" to PluginExample.pro.

Royceybaby
18th October 2006, 10:29
i am trying to compile the plugin and get the following error:


B:\Programming\PluginExample\PluginExample\plugins _source>qmake && make
make -f Makefile.Release
make[1]: Entering directory `B:/Programming/PluginExample/PluginExample/plugins_source'
g++ -c -O2 -O2 -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DMY_LIB_DLL -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -
I"C:/Devel/Qt/4.1.4/include/QtCore" -I"C:/Devel/Qt/4.1.4/include/QtGui" -I"C:/Devel/Qt/4.1.4/include" -I"C:/Devel/Qt/4.1.4/include/ActiveQt" -I"release" -I"." -I"c:\Devel
\Qt\4.1.4\mkspecs\win32-g++" -o release\helloworld_plugin.o helloworld_plugin.cpp
c:\Devel\Qt\4.1.4\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DMY_LIB_DLL -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"C:/Devel/
Qt/4.1.4/include/QtCore" -I"C:/Devel/Qt/4.1.4/include/QtGui" -I"C:/Devel/Qt/4.1.4/include" -I"C:/Devel/Qt/4.1.4/include/ActiveQt" -I"release" -I"." -I"c:\Devel\Qt\4.1.4\m
kspecs\win32-g++" -D__GNUC__ -DWIN32 helloworld_plugin.h -o release\moc_helloworld_plugin.cpp
g++ -c -O2 -O2 -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DMY_LIB_DLL -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -
I"C:/Devel/Qt/4.1.4/include/QtCore" -I"C:/Devel/Qt/4.1.4/include/QtGui" -I"C:/Devel/Qt/4.1.4/include" -I"C:/Devel/Qt/4.1.4/include/ActiveQt" -I"release" -I"." -I"c:\Devel
\Qt\4.1.4\mkspecs\win32-g++" -o release\moc_helloworld_plugin.o release\moc_helloworld_plugin.cpp
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-s -shared -Wl,--out-implib,..\plugins\libhelloworld_plugin.a
-o "..\plugins\helloworld_plugin.dll" release\helloworld_plugin.o release\moc_helloworld_plugin.o -L"c:\Devel\Qt\4.1.4\lib" -lQtGui -lgdi32 -lcomdlg32 -loleaut32 -limm32
-lwinmm -lwinspool -lmsimg32 -lQtCore -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32
Creating library file: ..\plugins\libhelloworld_plugin.a
release\helloworld_plugin.o(.text+0x33):helloworld _plugin.cpp: undefined reference to `_imp___ZN7QString11shared_nullE'
release\helloworld_plugin.o(.text+0x6a):helloworld _plugin.cpp: undefined reference to `_imp___ZN7QString9fromAsciiEPKci'
release\helloworld_plugin.o(.text+0x7f):helloworld _plugin.cpp: undefined reference to `_imp___ZN7QStringaSERKS_'
release\helloworld_plugin.o(.text+0xfe):helloworld _plugin.cpp: undefined reference to `_imp___ZN7QString4freeEPNS_4DataE'
release\helloworld_plugin.o(.text+0x122):helloworl d_plugin.cpp: undefined reference to `_imp___ZN7QString4freeEPNS_4DataE'
release\helloworld_plugin.o(.text+0x14f):helloworl d_plugin.cpp: undefined reference to `_imp___ZN11QMetaObject11removeGuardEPP7QObject'
release\helloworld_plugin.o(.text+0x21f):helloworl d_plugin.cpp: undefined reference to `_imp___ZN7QObjectC2EPS_'
release\helloworld_plugin.o(.text+0x254):helloworl d_plugin.cpp: undefined reference to `_imp___ZN11QMetaObject11changeGuardEPP7QObjectS1_ '
release\moc_helloworld_plugin.o(.text+0xd2):moc_he lloworld_plugin.cpp: undefined reference to `_imp___ZN7QObject16staticMetaObjectE'
release\moc_helloworld_plugin.o(.text$_ZN16HelloWo rldPluginD1Ev[HelloWorldPlugin::~HelloWorldPlugin()]+0x1b):moc_helloworld_plugin.cpp: undefined reference to `_imp___ZN7
QObjectD2Ev'
release\moc_helloworld_plugin.o(.text$_ZN16HelloWo rldPluginD0Ev[HelloWorldPlugin::~HelloWorldPlugin()]+0x1c):moc_helloworld_plugin.cpp: undefined reference to `_imp___ZN7
QObjectD2Ev'
collect2: ld returned 1 exit status
make[1]: *** [..\plugins\helloworld_plugin.dll] Error 1
make[1]: Leaving directory `B:/Programming/PluginExample/PluginExample/plugins_source'
make: *** [release] Error 2

Thanks,
Royce

Royceybaby
18th October 2006, 12:36
OK this may seem an extremely newbish reponse. But do I have to compile Qt into shared mode to allow plugins for my apps to be created?

It is just I downloaded Qt 4.2 and compiled a shared build instead of a static build. I was then able to compile my plugin into a .dll with no errors.

Royce

wysota
18th October 2006, 16:55
Qt is by default compiled in shared mode. You have to provide a "-static" parameter to configure to build a static library. If you want to use plugins, then of course you need a shared build.