Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. libUSB on MaxOs Sierra LINKER Problem (can't map file, errno=22)

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

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Barcley
    wrote on last edited by
    #1

    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
    
    TARGET = USBTMC
    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.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    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\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    

    Link to image: https://drive.google.com/open?id=0B4sCAnYsepnkak1nWklnaVV5VEk
    Image

    jsulmJ 1 Reply Last reply
    0
    • B Barcley

      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
      
      TARGET = USBTMC
      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.
      DEFINES += QT_DEPRECATED_WARNINGS
      
      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\
              mainwindow.cpp
      
      HEADERS  += mainwindow.h
      
      FORMS    += mainwindow.ui
      

      Link to image: https://drive.google.com/open?id=0B4sCAnYsepnkak1nWklnaVV5VEk
      Image

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Barcley Shouldn't it be

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

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • B Offline
        B Offline
        Barcley
        wrote on last edited by
        #3

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

        jsulmJ 1 Reply Last reply
        0
        • B Barcley

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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @Barcley Please read http://doc.qt.io/qt-5/third-party-libraries.html
          -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*

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          B 1 Reply Last reply
          1
          • jsulmJ jsulm

            @Barcley Please read http://doc.qt.io/qt-5/third-party-libraries.html
            -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*

            B Offline
            B Offline
            Barcley
            wrote on last edited by
            #5

            @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
            
            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved