Nominate our 2022 Qt Champions!

ZBar / QZBar -> error while loading shared libraries: cannot open shared object file: No such file or directory

  • Hi all,

    I want to use the ZBar / QZBar library for barcode scanning.
    I have included the header files in my source code and I think the libraries are also included correctly in the .pro file.

    INCLUDEPATH += $$PWD/QZBar/include
    INCLUDEPATH += $$PWD/QZBar/include/zbar
    LIBS += -L$$PWD/QZBar/ -lzbar
    PRE_TARGETDEPS += $$PWD/QZBar/libzbar.a
    LIBS += -L$$PWD/QZBar/ -lzbarqt
    PRE_TARGETDEPS += $$PWD/QZBar/libzbarqt.a
    QMAKE_LFLAGS += -Wl,-rpath,"'$$ORIGIN/QZBar'"

    But everytime I try to create a new instance of e.g. QZBar or ImageScanner, I get the error:

    error while loading shared libraries: cannot open shared object file: No such file or directory
    Child exited with status 127

    Does anyone know what is the cause for this?
    Has anyone used ZBar / QZBar successfully in qt / qml before and can share a running example?
    Maybe also a snippet of the .pro file how the libraries are included would be helpful.

    Kind regards,

  • Lifetime Qt Champion

    are those libzbar.a and libzbarqt.a compiled(created) with same compiler as
    the one you are using for the test program ?

  • @mrjj :
    Yes. I compiled the libraries with the same compiler.
    I have libzbar.a/.so and libzbarqt./.so.

  • Lifetime Qt Champion

    @MHermann Is the lib really inside $$PWD/QZBar? Maybe it is in a subdirectory? Can you post the linker call?

  • @jsulm : Sorry for answering late...
    Yes. I think it is in the right directory.

    Development environment:


    Running environment:


    And here is the linker call:

    g++ -Wl,-rpath,'/QZBar' -Wl,-rpath,/usr/local/qt5/lib -Wl,-rpath,/home/me/Qt/5.9.1/gcc_64/lib -Wl,-rpath-link,/home/me/Qt/5.9.1/gcc_64/lib -o CamTest main.o qzxingBarcodeReader.o adaptorQZXingBarcodeReader.o adaptorZBarBarcodeReader.o qzbarBarcodeReader.o CameraImageWrapper.o QZXing.o ImageHandler.o ResultIO.o InvertedLuminanceSource.o ChecksumException.o ResultPointCallback.o ResultPoint.o Result.o Reader.o MultiFormatReader.o LuminanceSource.o FormatException.o Exception.o DecodeHints.o BinaryBitmap.o Binarizer.o BarcodeFormat.o AztecReader.o AztecDetectorResult.o StringUtils.o Str.o PerspectiveTransform.o IllegalArgumentException.o HybridBinarizer.o GridSampler.o GreyscaleRotatedLuminanceSource.o GreyscaleLuminanceSource.o GlobalHistogramBinarizer.o DetectorResult.o DecoderResult.o CharacterSetECI.o BitSource.o BitMatrix.o BitArray.o BitArrayIO.o WhiteRectangleDetector.o MonochromeRectangleDetector.o ReedSolomonException.o ReedSolomonDecoder.o GenericGFPoly.o GenericGF.o DataMatrixReader.o UPCEReader.o UPCEANReader.o UPCAReader.o OneDResultPoint.o OneDReader.o MultiFormatUPCEANReader.o MultiFormatOneDReader.o ITFReader.o EAN13Reader.o EAN8Reader.o Code128Reader.o Code39Reader.o CodaBarReader.o Code93Reader.o QRCodeReader.o MultipleBarcodeReader.o GenericMultipleBarcodeReader.o ByQuadrantReader.o QRCodeMultiReader.o MultiFinderPatternFinder.o MultiDetector.o AztecDecoder.o AztecDetector.o DataMatrixVersion.o DataMatrixDecoder.o DataMatrixBitMatrixParser.o DataMatrixDataBlock.o DataMatrixDecodedBitStreamParser.o DataMatrixCornerPoint.o DataMatrixDetector.o DataMatrixDetectorException.o QRBitMatrixParser.o QRDataBlock.o QRDataMask.o QRDecodedBitStreamParser.o QRDecoder.o QRMode.o QRAlignmentPattern.o QRAlignmentPatternFinder.o QRDetector.o QRFinderPattern.o QRFinderPatternFinder.o QRFinderPatternInfo.o QRVersion.o QRFormatInformation.o QRErrorCorrectionLevel.o ErrorCorrection.o ModulusGF.o ModulusPoly.o PDF417BitMatrixParser.o PDF417DecodedBitStreamParser.o PDF417Decoder.o PDF417Detector.o LinesSampler.o PDF417Reader.o BigUnsignedInABase.o BigUnsigned.o BigIntegerUtils.o BigIntegerAlgorithms.o BigInteger.o ByteMatrix.o QREncoder.o MaskUtil.o MatrixUtil.o QRCode.o EncodeHint.o ReedSolomonEncoder.o qrc_qml.o moc_qzxingBarcodeReader.o moc_adaptorQZXingBarcodeReader.o moc_adaptorZBarBarcodeReader.o moc_qzbarBarcodeReader.o moc_ImageHandler.o moc_QZXing.o   -L/home/me/Repos/Cam_Test/QZBar/ -lzbar -lzbarqt -L/home/me/Qt/5.9.1/gcc_64/lib -lQt5Quick -lQt5MultimediaWidgets -lpulse-mainloop-glib -lpulse -lglib-2.0 -lQt5Widgets -lQt5Multimedia -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lGL -lpthread 

    I copied the folder with the libs and include files from my developing environment to my running environment. Is this correct? Maybe there are some problems with some links?

  • Lifetime Qt Champion

    @MHermann *.a are static libraries not shared.

  • @jsulm : All the libraries with the suffix .so are also in the same folders like the .a.

  • @jsulm : In the folder QZBar I have the following files:

    • libzbar.a


    • (link to

    • (link to


    • libzbarqt.a


    • (link to libzbarqt.0.0.2)

    • (link to libzbarqt.0.0.2)

    • libzbarqt.0.0.2

  • Lifetime Qt Champion

    @MHermann Your problem isn't building but starting the app, right?
    If so, then you need to deploy your app, see
    You need to create a directory containing your executable and needed libraries, else the loader cannot find these libraries as they are not in any of the directories the loader is looking into to find libraries. Try to copy into the same directory where your executable is.

  • @jsulm : Thanks for your answers.
    I found the solution. I had a typing error when indicating the LD_LIBRARY_PATH in the Run Environment.
    I corrected the path for LD_LIBRARY_PATH and now my application is running on the target system.

Log in to reply