【发布时间】: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