[英]QBS …/install-root/MyProject: error while loading shared libraries: foobar.so: cannot open shared object file: No such file or directory
Question is for solving this issue in qbs: 问题是为了在qbs中解决此问题:
Here is a file generated by QtCreator. 这是QtCreator生成的文件。 I added in
我加入了
cpp.dynamicLibraries:[
"/usr/lib/qconsoledesigner/libqconsoletoolkit.so"
]
in 在
CppApplication {
Depends { name: "Qt.core" }
Depends { name: "Qt.network" }
cpp.cxxLanguageVersion: "c++11"
cpp.defines: [
"QT_DEPRECATED_WARNINGS",
]
cpp.dynamicLibraries:[
"/usr/lib/qconsoledesigner/libqconsoletoolkit.so"
]
consoleApplication: true
files: "main.cpp"
Group { // Properties for the produced executable
fileTagsFilter: "application"
qbs.install: true
}
}
Here is the main(); 这是main();
#include <QCoreApplication>
#include "qconsoledesigner/qconsoletoolkit.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QConsoleToolkit ct;
return a.exec();
}
Everything builds fine. 一切都很好。 Running produces this error:
运行产生此错误:
/home/.../qtc_Desktop_Qt_5_10_1_GCC_64bit_qt_qt5_Debug/install-root/MyProject:
error while loading shared libraries:
libqconsoletoolkit.so:
cannot open shared object file:
No such file or directory
Before I physically copy that .so into my install root, I know there must be a QBS property that I can set. 在将那个.so物理复制到安装根目录之前,我知道必须有一个可以设置的QBS属性。
I have tried playing around with the various path related properties in https://doc.qt.io/qbs/qml-qbsmodules-cpp.html , but I am very much groping in the dark. 我尝试在https://doc.qt.io/qbs/qml-qbsmodules-cpp.html中尝试各种与路径相关的属性,但是我在黑暗中摸索着很多。
Thanks. 谢谢。
You can use rpath: https://doc.qt.io/qbs/qml-qbsmodules-cpp.html#rpaths-prop 您可以使用rpath: https : //doc.qt.io/qbs/qml-qbsmodules-cpp.html#rpaths-prop
For "local" use or if you can expect the library to be present wherever your app is installed, simply use the directory where the library is located in at build time: 对于“本地”使用,或者如果您希望库在安装应用程序的任何位置都存在,则只需在构建时使用库所在的目录即可:
cpp.rpaths: "/usr/lib/qconsoledesigner"
Otherwise, you will need to install the library along with your application and use a relative rpath. 否则,您将需要与应用程序一起安装该库,并使用相对的rpath。 At the moment, qbs has no convenience functionality for the former, so you'd write something like this:
目前,qbs没有前者的便利功能,因此您需要编写如下内容:
property stringList sharedLibsToDeploy: "/usr/lib/qconsoledesigner/libqconsoletoolkit.so"
cpp.dynamicLibraries: sharedLibsToDeploy
Group {
files: sharedLibsToDeploy
qbs.install: true
cpp.rpaths: cpp.rpathOrigin // if lib and app are installed into the same dir; adapt otherwise
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.