无法在 Linux Mint 18 或 Ubuntu 16.04 上编译 a4tech-bloody-linux-驱动程序

Unable to compile a4tech-bloody-linux-driver on Linux Mint 18, nor Ubuntu 16.04

因为买了A4Tech Bloody V8鼠标,所以想安装Linux的驱动,专门针对Linux Mint 18(Ubuntu 16.04 based)。

我在 GitHub 上找到了这个驱动程序:

https://github.com/maxmati/a4tech-bloody-linux-driver


由于没有关于如何安装它的文档,到目前为止我想出了如何为编译做准备:

首先我安装了cmake:

sudo apt-get install cmake

然后我为make准备了如下:

cmake .

我附上输出以供将来参考,但我没有看到任何错误:

-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vlastimil/Downloads/a4tech-bloody-linux-driver-master

我已尝试执行此问题页面上建议的所有步骤:https://github.com/maxmati/a4tech-bloody-linux-driver/issues/10

但是当运行这个:

rm CMakeCache.txt && cmake . && make clean && make

我收到这些错误:

Scanning dependencies of target bloody
[ 33%] Building CXX object CMakeFiles/bloody.dir/main.cpp.o
[ 66%] Building CXX object CMakeFiles/bloody.dir/Mouse.cpp.o
[100%] Linking CXX executable bloody
CMakeFiles/bloody.dir/Mouse.cpp.o: In function `Mouse::init()':
Mouse.cpp:(.text+0x18): undefined reference to `libusb_init'
Mouse.cpp:(.text+0x64): undefined reference to `libusb_set_debug'
CMakeFiles/bloody.dir/Mouse.cpp.o: In function `Mouse::discoverDevices()':
Mouse.cpp:(.text+0xa5): undefined reference to `libusb_get_device_list'
Mouse.cpp:(.text+0x10a): undefined reference to `libusb_get_device_descriptor'
Mouse.cpp:(.text+0x14c): undefined reference to `libusb_open'
Mouse.cpp:(.text+0x16e): undefined reference to `libusb_kernel_driver_active'
Mouse.cpp:(.text+0x18d): undefined reference to `libusb_detach_kernel_driver'
Mouse.cpp:(.text+0x1a6): undefined reference to `libusb_close'
Mouse.cpp:(.text+0x1cc): undefined reference to `libusb_get_device_address'
Mouse.cpp:(.text+0x215): undefined reference to `libusb_free_device_list'
CMakeFiles/bloody.dir/Mouse.cpp.o: In function `Mouse::~Mouse()':
Mouse.cpp:(.text+0x366): undefined reference to `libusb_close'
Mouse.cpp:(.text+0x391): undefined reference to `libusb_exit'
CMakeFiles/bloody.dir/Mouse.cpp.o: In function `Mouse::writeToMouse(unsigned char*, unsigned long)':
Mouse.cpp:(.text+0x497): undefined reference to `libusb_control_transfer'
CMakeFiles/bloody.dir/Mouse.cpp.o: In function `Mouse::readFromMouse(unsigned char*, unsigned long, unsigned char*, unsigned long)':
Mouse.cpp:(.text+0x548): undefined reference to `libusb_control_transfer'
CMakeFiles/bloody.dir/Mouse.cpp.o: In function `Mouse::listDevices()':
Mouse.cpp:(.text+0x6af): undefined reference to `libusb_get_device'
Mouse.cpp:(.text+0x6c6): undefined reference to `libusb_get_device_descriptor'
collect2: error: ld returned 1 exit status
CMakeFiles/bloody.dir/build.make:120: recipe for target 'bloody' failed
make[2]: *** [bloody] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/bloody.dir/all' failed
make[1]: *** [CMakeFiles/bloody.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

locate libusb.h

告诉我,它存在于:

/usr/include/libusb-1.0/libusb.h

但尝试使用 g++:

手动编译它
g++ main.cpp -lusb-1.0

说,没找到:

In file included from main.cpp:2:0:
Mouse.h:8:20: fatal error: libusb.h: No such file or directory
compilation terminated.

令人困惑。


生成的文件列表看起来不错:

ll

total 124K
-rw-r--r-- 1 vlastimil vlastimil 6.3K Nov 17 15:25 build.make
-rw-r--r-- 1 vlastimil vlastimil  276 Nov 17 15:25 cmake_clean.cmake
-rw-r--r-- 1 vlastimil vlastimil  551 Nov 17 15:25 CXX.includecache
-rw-r--r-- 1 vlastimil vlastimil  799 Nov 17 15:25 DependInfo.cmake
-rw-r--r-- 1 vlastimil vlastimil  445 Nov 17 15:25 depend.internal
-rw-r--r-- 1 vlastimil vlastimil  274 Nov 17 15:25 depend.make
-rw-r--r-- 1 vlastimil vlastimil  255 Nov 17 15:25 flags.make
-rw-r--r-- 1 vlastimil vlastimil  182 Nov 17 15:25 link.txt
-rw-r--r-- 1 vlastimil vlastimil 9.9K Nov 17 15:25 main.cpp.o
-rw-r--r-- 1 vlastimil vlastimil  69K Nov 17 15:25 Mouse.cpp.o
-rw-r--r-- 1 vlastimil vlastimil   64 Nov 17 15:25 progress.make

我就是没法link把它们拼成一个二进制文件,我直接试了:

/usr/bin/g++ -std=c++11 -I/usr/include/libusb-1.0 -L/usr/lib/x86_64-linux-gnu -lusb-1.0 main.cpp.o Mouse.cpp.o -o bloody

Mouse.cpp.o: In function `Mouse::init()':
Mouse.cpp:(.text+0x18): undefined reference to `libusb_init'
Mouse.cpp:(.text+0x64): undefined reference to `libusb_set_debug'
Mouse.cpp.o: In function `Mouse::discoverDevices()':
Mouse.cpp:(.text+0xa5): undefined reference to `libusb_get_device_list'
Mouse.cpp:(.text+0x10a): undefined reference to `libusb_get_device_descriptor'
Mouse.cpp:(.text+0x14c): undefined reference to `libusb_open'
Mouse.cpp:(.text+0x16e): undefined reference to `libusb_kernel_driver_active'
Mouse.cpp:(.text+0x18d): undefined reference to `libusb_detach_kernel_driver'
Mouse.cpp:(.text+0x1a6): undefined reference to `libusb_close'
Mouse.cpp:(.text+0x1cc): undefined reference to `libusb_get_device_address'
Mouse.cpp:(.text+0x215): undefined reference to `libusb_free_device_list'
Mouse.cpp.o: In function `Mouse::~Mouse()':
Mouse.cpp:(.text+0x366): undefined reference to `libusb_close'
Mouse.cpp:(.text+0x391): undefined reference to `libusb_exit'
Mouse.cpp.o: In function `Mouse::writeToMouse(unsigned char*, unsigned long)':
Mouse.cpp:(.text+0x497): undefined reference to `libusb_control_transfer'
Mouse.cpp.o: In function `Mouse::readFromMouse(unsigned char*, unsigned long, unsigned char*, unsigned long)':
Mouse.cpp:(.text+0x548): undefined reference to `libusb_control_transfer'
Mouse.cpp.o: In function `Mouse::listDevices()':
Mouse.cpp:(.text+0x6af): undefined reference to `libusb_get_device'
Mouse.cpp:(.text+0x6c6): undefined reference to `libusb_get_device_descriptor'
collect2: error: ld returned 1 exit status

我想知道这是否可能是 linker 的错误 (?)


我最后的想法是 link 将这两个目标文件放在一起:

g++ -o output main.cpp.o Mouse.cpp.o

但结果与上述直接尝试相同。


编译器版本为:

g++-5.real (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

我不知道如何进行下一步。感谢您的任何提示。

好吧,我在这方面遇到了很多麻烦,但最终我想通了。

可能有更好的解决方案,如果有,请添加您的解决方案。

复制此文件,无论出于何种原因,链接器未找到编译文件夹:

cp /usr/include/libusb-1.0/libusb.h ./

并手动调用编译:

g++ -std=c++11 main.cpp Mouse.cpp -I. -L. -L/usr/lib/x86_64-linux-gnu/  -lusb-1.0 -o "mouse-set-backlight"

这将创建 mouse-set-backlight 文件,此时无法识别我的鼠标。我明天会尝试解决。


Bloody V8 Core 2 修复:

编辑此文件:

Mouse.h

更改此行:

static const int BLOODY_V8_PID = 0x11F5;

至:

static const int BLOODY_V8_PID = 0x36E1;

然后重新编译。


如何修复 Bloody mouse 的未知版本,一般来说:

dmesg | grep Mouse

输出应该有点像我的:

[462227.138026] hid-generic 0003:09DA:36E1.0005: input,hidraw1: USB HID v1.11 Mouse [COMPANY USB Device] on usb-0000:00:14.0-2/input1

看这部分:

hid-generic 0003:09DA:36E1.0005

地址的第三部分,在我的例子中 36E1,就是你需要的。

加上0x前缀,即0x36E1

最后,像我上面那样编辑你的Mouse.h

然后重新编译。