rogueyoshi
rogueyoshi

Reputation: 57

Can't open QLibrary on linux

When I try to load a particular library stored in the same directory as the binary, I get an error:

Cannot load library uuirtdrv.so: (uuirtdrv.so: cannot open shared object file: No such file or directory)

But only on linux, not on windows. On windows it works like a charm.

QMake

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
 }

The QMake copies the library to the target directory.

main.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();

All main.cpp does is check if the library exists, and then try to load it. Not sure what could be wrong here. Do I need to put the .so into a specific directory? (The documentation mentions LD_LIBRARY_PATH on linux.)

EDIT: When I add an absolute path instead of a relative one, this error happens:

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)"

Upvotes: 0

Views: 730

Answers (1)

Knud Larsen
Knud Larsen

Reputation: 5899

libstdc++.so.5: cannot open shared object file: No such file or directory

Please install libstdc++5 : Fedora, CentOS → # yum install compat-libstdc++-33

New Fedora : # dnf install compat-libstdc++-33

Debian, Ubuntu : apt-get install libstdc++5

Upvotes: 1

Related Questions