我找到了以下用于在 Qt 中加载库的代码,但我不完全理解它是如何工作的。有人可以向我解释:typedef int (*MyPrototype)(int, int);
?
int r1 = 0;
QLibrary library("mathlib.so");
if (!library.load())
out << library.errorString() << endl;
if (library.load())
out << "library loaded" << endl;
typedef int (*MyPrototype)(int, int);
MyPrototype myFunction = (MyPrototype)library.resolve("add");
if (myFunction)
r1 = myFunction(a,b);
else
out << library.errorString() << endl;