【问题标题】:Unable to compile a4tech-bloody-linux-driver on Linux Mint 18, nor Ubuntu 16.04无法在 Linux Mint 18 和 Ubuntu 16.04 上编译 a4tech-bloody-linux-driver
【发布时间】:2016-11-17 17:55:24
【问题描述】:

由于我购买了 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

我不知道该怎么做。感谢您的任何提示。

【问题讨论】:

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


    【解决方案1】:

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

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

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

    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;
    

    然后再次编译。


    通常如何修复未知版本的血腥鼠标:

    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,类似于我上面的操作。

    然后再次编译。

    【讨论】:

      猜你喜欢
      • 2018-10-12
      • 2016-10-14
      • 2016-12-06
      • 1970-01-01
      • 2016-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-07
      相关资源
      最近更新 更多