libUSB on MaxOs Sierra LINKER Problem (can't map file, errno=22)

  • Hey folks,

    I'am getting crazy while trying to get the libusb library to run. Iam using MacOs Sierra with Qt Creator 4.2.1.
    I installed libusb via git.

    I always get the error message: can't map file, errno=22

    I think its just a linker problem. In the following code snippet and image my file path and the PRO-file are shown.

    Greetings Tobi

    # Project created by QtCreator 2017-02-08T23:15:27
    QT       += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TEMPLATE = app
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as been marked as deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    LIBS += /Users/tobias/Qt/includes/libusb/libusbĀ£ 
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    INCLUDEPATH += /Users/tobias/Qt/includes/libusb/libusb
    SOURCES += main.cpp\
    HEADERS  += mainwindow.h
    FORMS    += mainwindow.ui

    Link to image:

  • Moderators

    @Barcley Shouldn't it be

    LIBS += -L/Users/tobias/Qt/includes/libusb -lusb

    Also why is the library located in "includes" directory?

  • I just named the folder, in wich I cloned the git repository, "includes".

    Why do you add a "-L" in front of the path and what is "-lusb"?
    I have no library named "lusb"

    Thanks for your help :)

  • Moderators

    @Barcley Please read
    -L is used to specify the directory where to search for the lib
    -l specifies the library name (without lib prefix and without any suffixes)
    That means:

    LIBS += -L/Users/tobias/Qt/includes/libusb -lusb

    look in directory /Users/tobias/Qt/includes/libusb for a library named libusb*

  • @jsulm Ah thank you. Good to know :)

    I solved the problem with installing the library with homebrew:

    brew install libusb

    And set the paths in the .PRO-file to:

    # Link LIBUSB library
    LIBS += -L/usr/local/Cellar/libusb/1.0.21/lib -lusb-1.0
    # Path to LIBUSB library
    INCLUDEPATH += /usr/local/Cellar/libusb/1.0.21/include/libusb-1.0

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.