如何在Qt Creator中使用HIDAPI?

时间:2017-10-17 21:16:09

标签: linux qt linker-errors libusb-1.0 hidapi

我将整个hidapi-0.7.0下载(https://github.com/downloads/signal11/hidapi/hidapi-0.7.0.zip)解压缩到我的项目目录中,然后将hidapi-0.7.0/hidapi/hidapi.hhidapi-0.7.0/linux/hid-libusb.c添加到我的项目中。所以它们现在出现在我的*.pro文件中。

我安装了libusb-1.0(sudo apt-get install libusb-1.0-0-dev)并尝试构建项目。编译好了,但链接器做了这个:

hid-libusb.o: In function `libusb_get_string_descriptor':
/usr/include/libusb-1.0/libusb.h:1789: undefined reference to `libusb_control_transfer'
hid-libusb.o: In function `make_path':
/../hidapi-0.7.0/linux/hid-libusb.c:377: undefined reference to `libusb_get_device_address'
/../hidapi-0.7.0/linux/hid-libusb.c:376: undefined reference to `libusb_get_bus_number'
hid-libusb.o: In function `hid_init':
/../hidapi-0.7.0/linux/hid-libusb.c:388: undefined reference to `libusb_init'
hid-libusb.o: In function `hid_exit':
/../hidapi-0.7.0/linux/hid-libusb.c:399: undefined reference to `libusb_exit'
hid-libusb.o: In function `hid_enumerate':
/../hidapi-0.7.0/linux/hid-libusb.c:422: undefined reference to `libusb_get_device_list'
/../hidapi-0.7.0/linux/hid-libusb.c:431: undefined reference to `libusb_get_device_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:439: undefined reference to `libusb_get_active_config_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:441: undefined reference to `libusb_get_config_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:470: undefined reference to `libusb_open'
/../hidapi-0.7.0/linux/hid-libusb.c:545: undefined reference to `libusb_close'
/../hidapi-0.7.0/linux/hid-libusb.c:560: undefined reference to `libusb_free_config_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:564: undefined reference to `libusb_free_device_list'
hid-libusb.o: In function `read_callback':
/../hidapi-0.7.0/linux/hid-libusb.c:673: undefined reference to `libusb_submit_transfer'
hid-libusb.o: In function `read_thread':
/../hidapi-0.7.0/linux/hid-libusb.c:685: undefined reference to `libusb_alloc_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:697: undefined reference to `libusb_submit_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:705: undefined reference to `libusb_handle_events'
/../hidapi-0.7.0/linux/hid-libusb.c:714: undefined reference to `libusb_cancel_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:716: undefined reference to `libusb_handle_events'
hid-libusb.o: In function `hid_open_path':
/../hidapi-0.7.0/linux/hid-libusb.c:758: undefined reference to `libusb_get_device_list'
/../hidapi-0.7.0/linux/hid-libusb.c:763: undefined reference to `libusb_get_device_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:765: undefined reference to `libusb_get_active_config_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:778: undefined reference to `libusb_open'
/../hidapi-0.7.0/linux/hid-libusb.c:788: undefined reference to `libusb_kernel_driver_active'
/../hidapi-0.7.0/linux/hid-libusb.c:789: undefined reference to `libusb_detach_kernel_driver'
/../hidapi-0.7.0/linux/hid-libusb.c:791: undefined reference to `libusb_close'
/../hidapi-0.7.0/linux/hid-libusb.c:799: undefined reference to `libusb_claim_interface'
/../hidapi-0.7.0/linux/hid-libusb.c:803: undefined reference to `libusb_close'
/../hidapi-0.7.0/linux/hid-libusb.c:858: undefined reference to `libusb_free_config_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:862: undefined reference to `libusb_free_device_list'
hid-libusb.o: In function `hid_write':
/../hidapi-0.7.0/linux/hid-libusb.c:891: undefined reference to `libusb_control_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:910: undefined reference to `libusb_interrupt_transfer'
hid-libusb.o: In function `hid_send_feature_report':
/../hidapi-0.7.0/linux/hid-libusb.c:1059: undefined reference to `libusb_control_transfer'
hid-libusb.o: In function `hid_get_feature_report':
/../hidapi-0.7.0/linux/hid-libusb.c:1090: undefined reference to `libusb_control_transfer'
hid-libusb.o: In function `hid_close':
/../hidapi-0.7.0/linux/hid-libusb.c:1115: undefined reference to `libusb_cancel_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:1122: undefined reference to `libusb_free_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:1125: undefined reference to `libusb_release_interface'
/../hidapi-0.7.0/linux/hid-libusb.c:1128: undefined reference to `libusb_close'

自述文件简单地说:

  

要使用HIDAPI,只需将hid.c或hid-libusb.c放入您的   使用Makefile中的构建参数进行应用程序和构建。

这没有帮助。 (我如何确保QtC生成的Makefile在我不了解Makefile的时候就像那样工作?)

该网站说:

  

构建说明

     

...

     

Linux操作系统:
  切换到linux /目录并运行make。

但它做同样的事情:

~$ cd /../hidapi-0.7.0/linux
/../hidapi-0.7.0/linux$ make
cc -Wall -g -c -I../hidapi `pkg-config libusb-1.0 --cflags` hid-libusb.c -o hid-libusb.o
/bin/sh: 1: pkg-config: not found
hid-libusb.c: In function ‘hid_open_path’:
hid-libusb.c:748:13: warning: variable ‘num_devs’ set but not used [-Wunused-but-set-variable]
     ssize_t num_devs;
             ^
g++ -Wall -g  hid-libusb.o ../hidtest/hidtest.o `pkg-config libusb-1.0 libudev --libs` -o hidtest
/bin/sh: 1: pkg-config: not found
hid-libusb.o: In function `libusb_get_string_descriptor':
/usr/include/libusb-1.0/libusb.h:1789: undefined reference to `libusb_control_transfer'
hid-libusb.o: In function `new_hid_device':
/../hidapi-0.7.0/linux/hid-libusb.c:132: undefined reference to `pthread_barrier_init'
hid-libusb.o: In function `free_hid_device':
/../hidapi-0.7.0/linux/hid-libusb.c:140: undefined reference to `pthread_barrier_destroy'
hid-libusb.o: In function `make_path':
/../hidapi-0.7.0/linux/hid-libusb.c:377: undefined reference to `libusb_get_device_address'
/../hidapi-0.7.0/linux/hid-libusb.c:376: undefined reference to `libusb_get_bus_number'
hid-libusb.o: In function `hid_init':
/../hidapi-0.7.0/linux/hid-libusb.c:388: undefined reference to `libusb_init'
hid-libusb.o: In function `hid_exit':
/../hidapi-0.7.0/linux/hid-libusb.c:399: undefined reference to `libusb_exit'
hid-libusb.o: In function `hid_enumerate':
/../hidapi-0.7.0/linux/hid-libusb.c:422: undefined reference to `libusb_get_device_list'
/../hidapi-0.7.0/linux/hid-libusb.c:431: undefined reference to `libusb_get_device_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:439: undefined reference to `libusb_get_active_config_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:441: undefined reference to `libusb_get_config_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:470: undefined reference to `libusb_open'
/../hidapi-0.7.0/linux/hid-libusb.c:545: undefined reference to `libusb_close'
/../hidapi-0.7.0/linux/hid-libusb.c:560: undefined reference to `libusb_free_config_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:564: undefined reference to `libusb_free_device_list'
hid-libusb.o: In function `read_callback':
/../hidapi-0.7.0/linux/hid-libusb.c:673: undefined reference to `libusb_submit_transfer'
hid-libusb.o: In function `read_thread':
/../hidapi-0.7.0/linux/hid-libusb.c:685: undefined reference to `libusb_alloc_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:697: undefined reference to `libusb_submit_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:700: undefined reference to `pthread_barrier_wait'
/../hidapi-0.7.0/linux/hid-libusb.c:705: undefined reference to `libusb_handle_events'
/../hidapi-0.7.0/linux/hid-libusb.c:714: undefined reference to `libusb_cancel_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:716: undefined reference to `libusb_handle_events'
hid-libusb.o: In function `hid_open_path':
/../hidapi-0.7.0/linux/hid-libusb.c:758: undefined reference to `libusb_get_device_list'
/../hidapi-0.7.0/linux/hid-libusb.c:763: undefined reference to `libusb_get_device_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:765: undefined reference to `libusb_get_active_config_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:778: undefined reference to `libusb_open'
/../hidapi-0.7.0/linux/hid-libusb.c:788: undefined reference to `libusb_kernel_driver_active'
/../hidapi-0.7.0/linux/hid-libusb.c:789: undefined reference to `libusb_detach_kernel_driver'
/../hidapi-0.7.0/linux/hid-libusb.c:791: undefined reference to `libusb_close'
/../hidapi-0.7.0/linux/hid-libusb.c:799: undefined reference to `libusb_claim_interface'
/../hidapi-0.7.0/linux/hid-libusb.c:803: undefined reference to `libusb_close'
/../hidapi-0.7.0/linux/hid-libusb.c:848: undefined reference to `pthread_create'
/../hidapi-0.7.0/linux/hid-libusb.c:851: undefined reference to `pthread_barrier_wait'
/../hidapi-0.7.0/linux/hid-libusb.c:858: undefined reference to `libusb_free_config_descriptor'
/../hidapi-0.7.0/linux/hid-libusb.c:862: undefined reference to `libusb_free_device_list'
hid-libusb.o: In function `hid_write':
/../hidapi-0.7.0/linux/hid-libusb.c:891: undefined reference to `libusb_control_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:910: undefined reference to `libusb_interrupt_transfer'
hid-libusb.o: In function `hid_read_timeout':
/../hidapi-0.7.0/linux/hid-libusb.c:961: undefined reference to `__pthread_register_cancel'
/../hidapi-0.7.0/linux/hid-libusb.c:1029: undefined reference to `__pthread_unregister_cancel'
hid-libusb.o: In function `hid_send_feature_report':
/../hidapi-0.7.0/linux/hid-libusb.c:1059: undefined reference to `libusb_control_transfer'
hid-libusb.o: In function `hid_get_feature_report':
/../hidapi-0.7.0/linux/hid-libusb.c:1090: undefined reference to `libusb_control_transfer'
hid-libusb.o: In function `hid_close':
/../hidapi-0.7.0/linux/hid-libusb.c:1115: undefined reference to `libusb_cancel_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:1118: undefined reference to `pthread_join'
/../hidapi-0.7.0/linux/hid-libusb.c:1122: undefined reference to `libusb_free_transfer'
/../hidapi-0.7.0/linux/hid-libusb.c:1125: undefined reference to `libusb_release_interface'
/../hidapi-0.7.0/linux/hid-libusb.c:1128: undefined reference to `libusb_close'
collect2: error: ld returned 1 exit status
Makefile:25: recipe for target 'hidtest' failed
make: *** [hidtest] Error 1
/../hidapi-0.7.0/linux$ 

我是否仍然遗漏了某些东西(我希望如此),或者HIDAPI 0.7.0实际上已经损坏了,因为它甚至没有正确地开箱即用?

根据@ eyllanesc的评论进行实验:

/../hidapi-0.7.0/linux$ sudo apt-get install libudev-dev libusb-1.0-0-dev libfox-1.6-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libusb-1.0-0-dev is already the newest version (2:1.0.20-1).
The following additional packages will be installed:
  build-essential dpkg-dev libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libcups2-dev libexpat1-dev libfontconfig1-dev libfox-1.6-0 libfreetype6-dev libjbig-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev
  liblzma-dev libpng12-dev libtiff5-dev libtiffxx5 libxcursor-dev libxft-dev libxrender-dev pkg-config x11proto-render-dev
Suggested packages:
  debian-keyring libfox-1.6-doc liblzma-doc
The following NEW packages will be installed:
  build-essential dpkg-dev libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libcups2-dev libexpat1-dev libfontconfig1-dev libfox-1.6-0 libfox-1.6-dev libfreetype6-dev libjbig-dev libjpeg-dev libjpeg-turbo8-dev
  libjpeg8-dev liblzma-dev libpng12-dev libtiff5-dev libtiffxx5 libudev-dev libxcursor-dev libxft-dev libxrender-dev pkg-config x11proto-render-dev
0 upgraded, 25 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,865 kB of archives.
After this operation, 28.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 libfox-1.6-0 amd64 1.6.50-1 [879 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libudev-dev amd64 229-4ubuntu19 [150 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 dpkg-dev all 1.18.4ubuntu1.2 [584 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 build-essential amd64 12.1ubuntu2 [4,758 B]
Get:5 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-diff-perl all 1.19.03-1 [47.6 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-diff-xs-perl amd64 0.04-4build1 [11.0 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-merge-perl all 0.08-3 [12.0 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcups2-dev amd64 2.1.3-4ubuntu0.3 [239 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libexpat1-dev amd64 2.1.0-7ubuntu0.16.04.3 [115 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libpng12-dev amd64 1.2.54-1ubuntu1 [184 kB]
Get:11 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libfreetype6-dev amd64 2.6.1-0.1ubuntu2.3 [956 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 pkg-config amd64 0.29.1-0ubuntu1 [45.0 kB]
Get:13 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libfontconfig1-dev amd64 2.11.94-0ubuntu1.1 [658 kB]
Get:14 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libjpeg-turbo8-dev amd64 1.4.2-0ubuntu3 [254 kB]
Get:15 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libjpeg8-dev amd64 8c-2ubuntu8 [1,552 B]
Get:16 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libjpeg-dev amd64 8c-2ubuntu8 [1,546 B]
Get:17 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libjbig-dev amd64 2.1-3.1 [24.8 kB]
Get:18 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 liblzma-dev amd64 5.1.1alpha+20120614-2ubuntu2 [137 kB]
Get:19 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtiffxx5 amd64 4.0.6-1ubuntu0.2 [5,590 B]
Get:20 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtiff5-dev amd64 4.0.6-1ubuntu0.2 [267 kB]
Get:21 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 x11proto-render-dev all 2:0.11.1-2 [20.1 kB]
Get:22 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libxrender-dev amd64 1:0.9.9-0ubuntu1 [24.5 kB]
Get:23 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libxcursor-dev amd64 1:1.1.14-1 [29.8 kB]
Get:24 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libxft-dev amd64 2.3.2-1 [45.7 kB]
Get:25 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 libfox-1.6-dev amd64 1.6.50-1 [1,167 kB]
Fetched 5,865 kB in 3s (1,489 kB/s)        
Selecting previously unselected package libfox-1.6-0:amd64.
(Reading database ... 195066 files and directories currently installed.)
Preparing to unpack .../libfox-1.6-0_1.6.50-1_amd64.deb ...
Unpacking libfox-1.6-0:amd64 (1.6.50-1) ...
Selecting previously unselected package libudev-dev:amd64.
Preparing to unpack .../libudev-dev_229-4ubuntu19_amd64.deb ...
Unpacking libudev-dev:amd64 (229-4ubuntu19) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../dpkg-dev_1.18.4ubuntu1.2_all.deb ...
Unpacking dpkg-dev (1.18.4ubuntu1.2) ...
Selecting previously unselected package build-essential.
Preparing to unpack .../build-essential_12.1ubuntu2_amd64.deb ...
Unpacking build-essential (12.1ubuntu2) ...
Selecting previously unselected package libalgorithm-diff-perl.
Preparing to unpack .../libalgorithm-diff-perl_1.19.03-1_all.deb ...
Unpacking libalgorithm-diff-perl (1.19.03-1) ...
Selecting previously unselected package libalgorithm-diff-xs-perl.
Preparing to unpack .../libalgorithm-diff-xs-perl_0.04-4build1_amd64.deb ...
Unpacking libalgorithm-diff-xs-perl (0.04-4build1) ...
Selecting previously unselected package libalgorithm-merge-perl.
Preparing to unpack .../libalgorithm-merge-perl_0.08-3_all.deb ...
Unpacking libalgorithm-merge-perl (0.08-3) ...
Selecting previously unselected package libcups2-dev:amd64.
Preparing to unpack .../libcups2-dev_2.1.3-4ubuntu0.3_amd64.deb ...
Unpacking libcups2-dev:amd64 (2.1.3-4ubuntu0.3) ...
Selecting previously unselected package libexpat1-dev:amd64.
Preparing to unpack .../libexpat1-dev_2.1.0-7ubuntu0.16.04.3_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.1.0-7ubuntu0.16.04.3) ...
Selecting previously unselected package libpng12-dev:amd64.
Preparing to unpack .../libpng12-dev_1.2.54-1ubuntu1_amd64.deb ...
Unpacking libpng12-dev:amd64 (1.2.54-1ubuntu1) ...
Selecting previously unselected package libfreetype6-dev:amd64.
Preparing to unpack .../libfreetype6-dev_2.6.1-0.1ubuntu2.3_amd64.deb ...
Unpacking libfreetype6-dev:amd64 (2.6.1-0.1ubuntu2.3) ...
Selecting previously unselected package pkg-config.
Preparing to unpack .../pkg-config_0.29.1-0ubuntu1_amd64.deb ...
Unpacking pkg-config (0.29.1-0ubuntu1) ...
Selecting previously unselected package libfontconfig1-dev:amd64.
Preparing to unpack .../libfontconfig1-dev_2.11.94-0ubuntu1.1_amd64.deb ...
Unpacking libfontconfig1-dev:amd64 (2.11.94-0ubuntu1.1) ...
Selecting previously unselected package libjpeg-turbo8-dev:amd64.
Preparing to unpack .../libjpeg-turbo8-dev_1.4.2-0ubuntu3_amd64.deb ...
Unpacking libjpeg-turbo8-dev:amd64 (1.4.2-0ubuntu3) ...
Selecting previously unselected package libjpeg8-dev:amd64.
Preparing to unpack .../libjpeg8-dev_8c-2ubuntu8_amd64.deb ...
Unpacking libjpeg8-dev:amd64 (8c-2ubuntu8) ...
Selecting previously unselected package libjpeg-dev:amd64.
Preparing to unpack .../libjpeg-dev_8c-2ubuntu8_amd64.deb ...
Unpacking libjpeg-dev:amd64 (8c-2ubuntu8) ...
Selecting previously unselected package libjbig-dev:amd64.
Preparing to unpack .../libjbig-dev_2.1-3.1_amd64.deb ...
Unpacking libjbig-dev:amd64 (2.1-3.1) ...
Selecting previously unselected package liblzma-dev:amd64.
Preparing to unpack .../liblzma-dev_5.1.1alpha+20120614-2ubuntu2_amd64.deb ...
Unpacking liblzma-dev:amd64 (5.1.1alpha+20120614-2ubuntu2) ...
Selecting previously unselected package libtiffxx5:amd64.
Preparing to unpack .../libtiffxx5_4.0.6-1ubuntu0.2_amd64.deb ...
Unpacking libtiffxx5:amd64 (4.0.6-1ubuntu0.2) ...
Selecting previously unselected package libtiff5-dev:amd64.
Preparing to unpack .../libtiff5-dev_4.0.6-1ubuntu0.2_amd64.deb ...
Unpacking libtiff5-dev:amd64 (4.0.6-1ubuntu0.2) ...
Selecting previously unselected package x11proto-render-dev.
Preparing to unpack .../x11proto-render-dev_2%3a0.11.1-2_all.deb ...
Unpacking x11proto-render-dev (2:0.11.1-2) ...
Selecting previously unselected package libxrender-dev:amd64.
Preparing to unpack .../libxrender-dev_1%3a0.9.9-0ubuntu1_amd64.deb ...
Unpacking libxrender-dev:amd64 (1:0.9.9-0ubuntu1) ...
Selecting previously unselected package libxcursor-dev:amd64.
Preparing to unpack .../libxcursor-dev_1%3a1.1.14-1_amd64.deb ...
Unpacking libxcursor-dev:amd64 (1:1.1.14-1) ...
Selecting previously unselected package libxft-dev.
Preparing to unpack .../libxft-dev_2.3.2-1_amd64.deb ...
Unpacking libxft-dev (2.3.2-1) ...
Selecting previously unselected package libfox-1.6-dev.
Preparing to unpack .../libfox-1.6-dev_1.6.50-1_amd64.deb ...
Unpacking libfox-1.6-dev (1.6.50-1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Setting up libfox-1.6-0:amd64 (1.6.50-1) ...
Setting up libudev-dev:amd64 (229-4ubuntu19) ...
Setting up dpkg-dev (1.18.4ubuntu1.2) ...
Setting up build-essential (12.1ubuntu2) ...
Setting up libalgorithm-diff-perl (1.19.03-1) ...
Setting up libalgorithm-diff-xs-perl (0.04-4build1) ...
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up libcups2-dev:amd64 (2.1.3-4ubuntu0.3) ...
Setting up libexpat1-dev:amd64 (2.1.0-7ubuntu0.16.04.3) ...
Setting up libpng12-dev:amd64 (1.2.54-1ubuntu1) ...
Setting up libfreetype6-dev:amd64 (2.6.1-0.1ubuntu2.3) ...
Setting up pkg-config (0.29.1-0ubuntu1) ...
Setting up libfontconfig1-dev:amd64 (2.11.94-0ubuntu1.1) ...
Setting up libjpeg-turbo8-dev:amd64 (1.4.2-0ubuntu3) ...
Setting up libjpeg8-dev:amd64 (8c-2ubuntu8) ...
Setting up libjpeg-dev:amd64 (8c-2ubuntu8) ...
Setting up libjbig-dev:amd64 (2.1-3.1) ...
Setting up liblzma-dev:amd64 (5.1.1alpha+20120614-2ubuntu2) ...
Setting up libtiffxx5:amd64 (4.0.6-1ubuntu0.2) ...
Setting up libtiff5-dev:amd64 (4.0.6-1ubuntu0.2) ...
Setting up x11proto-render-dev (2:0.11.1-2) ...
Setting up libxrender-dev:amd64 (1:0.9.9-0ubuntu1) ...
Setting up libxcursor-dev:amd64 (1:1.1.14-1) ...
Setting up libxft-dev (2.3.2-1) ...
Setting up libfox-1.6-dev (1.6.50-1) ...
update-alternatives: using /usr/bin/fox-config-1.6 to provide /usr/bin/fox-config (fox-config) in auto mode
update-alternatives: using /usr/bin/reswrap-1.6 to provide /usr/bin/reswrap (reswrap) in auto mode
Processing triggers for libc-bin (2.23-0ubuntu9) ...

/../hidapi-0.7.0/linux$ make clean
rm -f hid-libusb.o ../hidtest/hidtest.o hidtest

/../hidapi-0.7.0/linux$ make
cc -Wall -g -c -I../hidapi `pkg-config libusb-1.0 --cflags` hid-libusb.c -o hid-libusb.o
hid-libusb.c: In function ‘hid_open_path’:
hid-libusb.c:748:13: warning: variable ‘num_devs’ set but not used [-Wunused-but-set-variable]
     ssize_t num_devs;
             ^
g++ -Wall -g -c -I../hidapi `pkg-config libusb-1.0 --cflags` ../hidtest/hidtest.cpp -o ../hidtest/hidtest.o
g++ -Wall -g  hid-libusb.o ../hidtest/hidtest.o `pkg-config libusb-1.0 libudev --libs` -o hidtest
/usr/bin/ld: hid-libusb.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:25: recipe for target 'hidtest' failed
make: *** [hidtest] Error 1

/../hidapi-0.7.0/linux$ 

不喜欢这样,但至少它是一个不同的错误,所以它可能是某种进步。不幸的是,我不知道这个意味着什么。

1 个答案:

答案 0 :(得分:0)

d' OH !!!我错过了http://www.eliasing.com/qt/hid-qt的这一部分:

  

将以下内容添加到* .pro文件中:

     

macx:SOURCES + = mac / hid.c
  unix:!macx:SOURCES + = linux / hid-libusb.c
  win32:SOURCES + = windows / hid.cpp

     

macx:LIBS + = -framework CoreFoundation -framework IOkit
  unix:!macx:LIBS + = -lusb-1.0
  win32:LIBS + = -lSetupAPI

所以它实际上并没有查看已安装的库。它现在有效!

注意:此部分 是必要的,至少对于hidapi-0.7.0

  

您可能还需要在hid-libusb.c中替换以下内容

     

#include" libusb.h"
  被替换为:
  #include" libusb-1.0 / libusb.h"

如果您决定将整个hidapi目录复制到项目而不仅仅是指定的文件中,您可能还需要更正下面的#include "hidapi.h"行。