Yes, you want to use a class QLibrary. It is specifically designed to load shared libraries at runtime.
.pro. , DLL . , (PATH Windows, LD_LIBRARY_PATH Linux, DYLD_LIBRARY_PATH Mac), .
, , , "func1()" .
[EDIT]
dll , . IMO, , Windows 7. - , , ..
foo.cpp,
#include <QtCore/qglobal.h>
extern "C" Q_DECL_EXPORT int foo(int value) {
return value + 42;
}
bar.pro, foo library
SOURCES += main.cpp
RESOURCES += resources.qrc
main.cpp
#include <QtCore>
#include <iostream>
int main(int argc, char **argv) {
QCoreApplication app(argc, argv);
QFile::copy(":/lib/Foo.dll", QDir::temp().filePath("Foo.dll"));
QLibrary foo_lib(QDir::temp().filePath("Foo.dll"));
typedef int (*FooDelegate)(int);
FooDelegate foo = (FooDelegate)foo_lib.resolve("foo");
if (foo) {
std::cout << "foo(13) = " << foo(13) << std::endl;
}
}