簡體   English   中英

QBS…/ install-root / MyProject:加載共享庫時出錯:foobar.so:無法打開共享對象文件:沒有這樣的文件或目錄

[英]QBS …/install-root/MyProject: error while loading shared libraries: foobar.so: cannot open shared object file: No such file or directory

問題是為了在qbs中解決此問題:

這是QtCreator生成的文件。 我加入了

cpp.dynamicLibraries:[
   "/usr/lib/qconsoledesigner/libqconsoletoolkit.so"
]

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
    }
}

這是main();

#include <QCoreApplication>
#include "qconsoledesigner/qconsoletoolkit.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QConsoleToolkit ct;

    return a.exec();
}

一切都很好。 運行產生此錯誤:

/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

在將那個.so物理復制到安裝根目錄之前,我知道必須有一個可以設置的QBS屬性。

我嘗試在https://doc.qt.io/qbs/qml-qbsmodules-cpp.html中嘗試各種與路徑相關的屬性,但是我在黑暗中摸索着很多。

謝謝。

您可以使用rpath: https : //doc.qt.io/qbs/qml-qbsmodules-cpp.html#rpaths-prop

對於“本地”使用,或者如果您希望庫在安裝應用程序的任何位置都存在,則只需在構建時使用庫所在的目錄即可:

cpp.rpaths: "/usr/lib/qconsoledesigner"

否則,您將需要與應用程序一起安裝該庫,並使用相對的rpath。 目前,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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM