- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我发现了以下用于在 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;
最佳答案
so或者dll有函数,我们要用,怎么调用
int add(int in_iParam1, int in_iParam2)
定义函数类型
typedef int (*MyPrototype)(int, int);
在so文件中寻找'add'函数
MyPrototype myFunction = (MyPrototype)library.resolve("add");
使用参数 'a' 和 'b' 调用函数 'add' 并将结果传给 'r1'
r1 = myFunction(a,b);
关于c++ - 使用 QLibrary 加载库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45119131/
我正在使用 QLibrary 从一个 .dll 文件加载函数。我成功加载它,成功解析功能。但是当我第一次使用那个 .dll 中的某些函数时,这个函数运行起来非常慢(即使它是一个非常简单的函数)。下次我
我有一个 QT 库,我想将它导入到另一个项目中。 现在,既然我想要那个,即使我修改了库,另一个项目也不需要重新编译,我开始使用 QLibrary。 但是...我无法导入类。或者更好的是,我可以导入该类
QLibrary可以很好地从.so库的一个实例中获取一组函数指针。但是,当尝试从同一个.so文件中获取函数指针的两个不同实例时,它不起作用。两组指针均指向内存中的相同位置,从而使其变得多余且无用。根据
我发现了以下用于在 Qt 中加载库的代码,但我不完全理解它是如何工作的。有人能给我解释一下吗:typedef int (*MyPrototype)(int, int);? int r1 = 0; QL
我现在正在尝试动态包含类文件,并选择通过将 .dll 加载到 QLibrary 中来实现。我现在遇到的问题是,当我尝试调用 resolve() 方法时,它返回 0。 编辑:与此同时,问题已经解决,我决
让我们考虑 Qt 文档中的这个片段: QLibrary myLib("mylib"); typedef void (*MyPrototype)(); MyPrototype myFunction =
我有一个动态加载 B.so 的可执行文件 A,而 B.so 又依赖于 C.so。 C.so 与 A 和 B 不在同一个文件夹中。 我正在尝试使用 QLibrary.load() 加载 B.so 但未能
当我尝试加载与二进制文件存储在同一目录中的特定库时,出现错误: Cannot load library uuirtdrv.so: (uuirtdrv.so: cannot open shared ob
我正在做一个大项目,我试图用 QLibrary 动态加载一个共享库,我能够在下面重现运行时链接错误(undefined symbol: staticMetaObject)示例: 文件夹结构: root
我已经成功编译了 MySQL 驱动程序,但我无法强制 Qt 加载它们。 一开始应该说的是,我在安装包中获得了 ODBC 和 SQLite 驱动程序(在安装 Qt 之后),但也没有检测到它们。 在 *C
我是一名优秀的程序员,十分优秀!