HIDAPI with Qt5- compiling error
-
wrote on 25 Jan 2017, 07:40 last edited by
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 -
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@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). -
wrote on 25 Jan 2017, 10:26 last edited by
did as you told, but getting same error message.
-
@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).wrote on 25 Jan 2017, 10:56 last edited by SGaist@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 ]
-
Hi and welcome to devnet,
You are missing
win32 { LIBS += -lhid -lsetupapi }
in your .pro file.
-
Hi and welcome to devnet,
You are missing
win32 { LIBS += -lhid -lsetupapi }
in your .pro file.
-
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 :)
1/7