- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
当我尝试加载与二进制文件存储在同一目录中的特定库时,出现错误:
Cannot load library uuirtdrv.so: (uuirtdrv.so: cannot open shared object file: No such file or directory)
但仅限于 linux,不适用于 windows。在 Windows 上,它就像一个魅力。
Q制作
QT += core serialport
QT -= gui
CONFIG += c++11
TARGET = serial-test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
win32 {
dll.files += $$PWD/uuirtdrv.dll
dll.path = $$OUT_PWD
INSTALLS += dll
}
unix {
so.files += $$PWD/uuirtdrv.so
so.path = $$OUT_PWD
INSTALLS += so
}
QMake 将库复制到目标目录。
主要.cpp
if (!QLibrary::isLibrary("uuirtdrv.so"))
{
qDebug() << "uuirtdrv does not exist.";
}
qDebug() << "Loading uuirtdrv";
QLibrary hinstLib;
hinstLib.setFileName("uuirtdrv.so");
if (hinstLib.load()) qDebug() << "uuirtdrv loaded.";
else qDebug() << hinstLib.errorString();
所有 main.cpp 所做的就是检查库是否存在,然后尝试加载它。不知道这里可能出了什么问题。我是否需要将 .so 放入特定目录? (文档在 linux 上提到了 LD_LIBRARY_PATH。)
编辑:当我添加绝对路径而不是相对路径时,会发生此错误:
Cannot load library /media/sf_Qt/build-serial-test-Desktop-Debug/uuirtdrv.so: (libstdc++.so.5: cannot open shared object file: No such file or directory)"
最佳答案
libstdc++.so.5: cannot open shared object file: No such file or directory
请安装 libstdc++5 : Fedora, CentOS → # yum install compat-libstdc++-33
新版 Fedora:# dnf install compat-libstdc++-33
Debian、Ubuntu:apt-get install libstdc++5
关于c++ - 无法在 Linux 上打开 QLibrary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43983501/
我正在使用 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
我是一名优秀的程序员,十分优秀!