PDA

View Full Version : Qt plugins - how to do a libtool-style autoload



KShots
7th February 2007, 03:23
Hello all,

I was hoping to create a project in which I would make use of plugins to implement much of the functionality of the finished project. Unfortunately, from what I've been reading in the documentation, QPluginLoader does not support automatically searching a given directory for plugins and loading them (similar to the libtool function lt_dlforeachfile(const char * search_path, int (*func) (const char * filename, lt_ptr data), lt_ptr data) (http://www.gnu.org/software/libtool/manual.html#Libltdl-interface). In other words, I want to be able to load all plugins in a given folder, and I don't want to have to write a custom plugin finder that works for all conceivable architectures with all conceivable plugin extension names (.dll, .so, and likely another 10 or so possibilities).

Is Qt capable of this, or should I just bite the bullet and find some way of using libtool?

wysota
7th February 2007, 09:19
Oh come on...

#ifdef Q_WS_WIN
# define PLUG_EXT "*.dll"
#elif defined Q_WS_MAC
# define PLUG_EXT "*.dylib"
#else
# define PLUG_EXT "*.so"
#endif

QDir d = QDir::current();
QStringList pluginlist = d.entryList(PLUG_EXT, QDir::Files|QDir::Readable);

KShots
7th February 2007, 12:40
Is that really all the options available? I know that covers linux, *BSD, Solaris, Mac, and Windows (I have access to these machines), but what about the more exotic OS's? I may be way wrong here, but aren't there other extensions?