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. HIDAPI with Qt5- compiling error
Forum Update on Monday, May 27th 2025

HIDAPI with Qt5- compiling error

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 3.0k 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.
  • O Offline
    O Offline
    o6a6r9v1p
    wrote on 25 Jan 2017, 07:40 last edited by
    #1

    I am new to QT, and working with HIDAPI for Microchip Mcus. I have compiled the example code for HIDAPI and it is giving "undefined reference to 'hid_open' " error. All the source files are copied into project folder. Even then i am getting similar error for six functions that are defined in hidapi.c file. we are using Qt Creator 4.2.0 (4.2.0) Based on Qt 5.7.1.
    I have gone through related posts in Qt forum & in net, but could not find a solution. Please give clues about problem.
    Thanks

    J 1 Reply Last reply 25 Jan 2017, 08:21
    0
    • O o6a6r9v1p
      25 Jan 2017, 07:40

      I am new to QT, and working with HIDAPI for Microchip Mcus. I have compiled the example code for HIDAPI and it is giving "undefined reference to 'hid_open' " error. All the source files are copied into project folder. Even then i am getting similar error for six functions that are defined in hidapi.c file. we are using Qt Creator 4.2.0 (4.2.0) Based on Qt 5.7.1.
      I have gone through related posts in Qt forum & in net, but could not find a solution. Please give clues about problem.
      Thanks

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 25 Jan 2017, 08:21 last edited by
      #2

      @o6a6r9v1p "undefined reference to 'hid_open' " - means you either do not link against the library containing hid_open or you did not add the source file containing the hid_open definition to your project if you do not use the library.
      Just copying the files into your project directory doesn't mean they are built. You need to add them in your pro file (rerun qmake after changing pro file).

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

      O 1 Reply Last reply 25 Jan 2017, 10:56
      1
      • O Offline
        O Offline
        o6a6r9v1p
        wrote on 25 Jan 2017, 10:26 last edited by
        #3

        did as you told, but getting same error message.

        1 Reply Last reply
        0
        • J jsulm
          25 Jan 2017, 08:21

          @o6a6r9v1p "undefined reference to 'hid_open' " - means you either do not link against the library containing hid_open or you did not add the source file containing the hid_open definition to your project if you do not use the library.
          Just copying the files into your project directory doesn't mean they are built. You need to add them in your pro file (rerun qmake after changing pro file).

          O Offline
          O Offline
          o6a6r9v1p
          wrote on 25 Jan 2017, 10:56 last edited by SGaist
          #4

          @jsulm
          Thanks for your input. I did as you told.
          pro file contents looks as below:

          #begins here 
          QT       += core gui
          
          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
          
          TARGET = HID_PnP_Demo
          TEMPLATE = app
          
          DEFINES += QT_DEPRECATED_WARNINGS
          
          
          SOURCES += main.cpp\
                  demoapp.cpp \
              hid_pnp.cpp \
              hidapi.cpp
          
          HEADERS  += demoapp.h \
              hid_pnp.h \
              hidapi.h    \
              ui_demoapp.h
          
          FORMS    += demoapp.ui
          
          #end of file
          

          I am getting now the following type of error for 6 functions defined in hidapi.cpp

          C:\Users\Documents\HID_PnP_Demo\HID_PnP_Demo\hidapi.cpp:286: error: undefined reference to `_imp__SetupDiGetClassDevsA@16'

          In net, it is said to be linker/path problem. Where shall i set them?
          Thanks

          [edit: added coding tags three back-ticks before and after SGaist ]

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 25 Jan 2017, 11:11 last edited by SGaist
            #5

            Hi and welcome to devnet,

            You are missing

            win32 {
               LIBS += -lhid -lsetupapi
            }
            

            in your .pro file.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            O 1 Reply Last reply 25 Jan 2017, 11:21
            1
            • S SGaist
              25 Jan 2017, 11:11

              Hi and welcome to devnet,

              You are missing

              win32 {
                 LIBS += -lhid -lsetupapi
              }
              

              in your .pro file.

              O Offline
              O Offline
              o6a6r9v1p
              wrote on 25 Jan 2017, 11:21 last edited by
              #6

              @SGaist
              Thank you and @jsulm for your quick help. Now project is compiled & I getting the GUI.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 25 Jan 2017, 11:25 last edited by
                #7

                Great !

                In that case please mark the thread as solved using the "Topic Tools" button so other forum users may know a solution has been found :)

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                1/7

                25 Jan 2017, 07:40

                • Login

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