linux - 无法在 Linux Mint 18 或 Ubuntu 16.04 上编译 a4tech-bloody-linux-driver

标签 linux compiler-errors cmake g++ ubuntu-16.04

因为我买了 A4Tech Bloody V8 鼠标,所以我想安装 Linux 的驱动程序,专门用于 Linux Mint 18(基于 Ubuntu 16.04)。

我在 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

我只是无法将它们链接到一个二进制文件中,我直接试过了:

/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

我想知道这是否可能是链接器的错误(?)


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

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

然后再次编译。

关于linux - 无法在 Linux Mint 18 或 Ubuntu 16.04 上编译 a4tech-bloody-linux-driver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40661841/

相关文章:

compiler-errors - Xcode 10 编译时错误 :Segmentation fault 11

c++ - 严重错误C1083

cmake - 如何在cmake中控制构建模式(调试或发布)?

c++ - 在 CMake 中混合 C 和 C++,什么是 CMakeCCompilerId.c 以及如何丢弃它

java - 缺少单独的调试信息,请使用 : debuginfo-install glibc-2. 12-1.166.el6_7.7.x86_64

linux - 使用适当的 POSIX 信号

C - 打印没有标准库的参数

linux - 从 bash 在默认编辑器中打开文件

gcc - 区分 gcc 诊断

C++ 可执行文件有时会无缘无故地快 3 倍