PDA

View Full Version : Problems loading static plugins



Rodrigo
10th July 2007, 13:29
Hello there! :D

Since yesterday, i've trying to load a static plugin in my application, but i didn't get good results.

i followed the steps mentioneds at trolltech's site.

1. Add CONFIG += static to your plugin's .pro file.


...
CONFIG += static
...


2. Use the Q_IMPORT_PLUGIN() macro in your application.



...
Q_IMPORT_PLUGIN(libxatp)
...


and finally

3. Link your application with your plugin library using LIBS in the .pro file.



...
LIBS += libxatp.a
...


i tried only put libxatp, but the compiler don't find the file.

g++: libxatp: File or directory not found

how you can see, i followed the steps, but when i compile my project, i get the following error message:

main.o: In function `__static_initialization_and_destruction_0(int, int)':
==== > main.cpp:(.text+0x1b): undefined reference to `qt_plugin_instance_libxatp()'
collect2: ld returned 1 exit status
make[1]: ** [../bin/xp] Erro 1
make: ** [sub-src-make_default] Erro 2
*** Saiu com estado: 2 ***

I don't know what to do to solve this problem pointed above. :confused:

Thank in advance

Rodrigo Amorim

ps.: sorry about my poor english! :o

jpn
10th July 2007, 19:32
Try with following:

Plugin (plugin.cpp):

Q_EXPORT_PLUGIN2(xatp, PluginClassName)

App (main.cpp):

Q_IMPORT_PLUGIN(xatp)

In case it still doesn't work, try going through the plug and paint example (http://doc.trolltech.com/4.3/tools-plugandpaint.html) and your project side by side comparing used macros and file/class names. If still in doubt, attach the project and we'll take a look. :)

PS. The plug and paint example (http://doc.trolltech.com/4.3/tools-plugandpaint.html) can be found in <QTDIR>\examples\tools\plugandpaint and <QTDIR>\examples\tools\plugandpaintplugins. You're especially interested into basic tools plugin (http://doc.trolltech.com/4.3/tools-plugandpaintplugins-basictools.html) which is static.

Rodrigo
11th July 2007, 12:42
Thanks JPN, i fixed the macro Q_EXPORT_PLUGIN2 and now it works perfectly!

Bye!