0

Question is for solving this issue in qbs:

Here is a file generated by 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();

#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.

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.

Thanks.

Anon
  • 2,267
  • 3
  • 34
  • 51

1 Answers1

0

You can use 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. At the moment, qbs has no convenience functionality for the former, so you'd write something like this:

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
}