libusb 和 usbutils 的交叉编译

libusb 下载地址: https://sourceforge.net/projects/libusb/

usbutils 下载地址:https://mirrors.edge.kernel.org/pub/linux/utils/usb/usbutils/

我使用的是 libusb-1.0.22 和 usbutils-005

 

libusb 交叉编译:

./configure CC={编译器目录}/mipsel-linux-gcc --build=i686-linux --host=mipsel-linux --prefix={安装目录} --disable-udev && make && make install

usbutils 交叉编译:

./configure CC={编译器目录}/mipsel-linux-gcc --build=i686-linux --host=mipsel-linux --prefix={安装目录} --datarootdir=/tmp

执行以上 configure 会报错如下,找不到 libusb 的 pkg-config,此时需要指定 PKG_CONFIG_PATH={libusb所在目录}

configure: error: Package requirements (libusb-1.0 >= 1.0.0) were not met:

Package libusb-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libusb-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libusb-1.0' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBUSB_CFLAGS
and LIBUSB_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

 

再次 configure 会报错如下,需要更改 usbhid-dump/configure,指定 libusb-1.0.so 所在目录

checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for libusb_init in -lusb-1.0... no
configure: error: in `/home/chengc/otherGround/software/usbutils-005/usbhid-dump':
configure: error: libusb is required, but was not found, abort.
                     Try installing libusb-1.0-0-dev or libusb1-devel.
See `config.log' for more details
configure: error: ./configure failed for usbhid-dump

再次 configure,结果如下:

config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands

	usbutils 005
	=============

	prefix:                 /home/**************
	datarootdir:            /tmp
	datadir:                ${datarootdir}
	mandir:                 ${datarootdir}/man

	usb.ids:                ${datarootdir}/usb.ids
	zlib:

	compiler:               /opt/trendchip/mipsel-linux-glibc-4.6.3-kernel3.18/usr/bin/mipsel-linux-gcc
	cflags:                 -g -O2
	ldflags:

make 时可能报错如下,将 libusb 安装目录中的 include/libusb-1.0 拷贝到 usbhid-dump/include/ 即可 

usbutils-005/usbhid-dump/include/uhd/dev.h:31:31: fatal error: libusb-1.0/libusb.h: No such file or directory

最后 make && make install 即可。

 

lsusb 命令使用时需要 usb.ids 这个文件,这个文件在 usbutils 根目录下,将这个文件 拷贝到 编译 usbutils 时指定的 {datarootdir} 目录即可.

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WSL是Windows Subsystem for Linux的缩写,是Windows 10中的一个功能,允许用户在Windows操作系统中运行Linux环境。USB Storage是指通过USB接口连接计算机的存储设备,如U盘、移动硬盘等。 在WSL中使用USB Storage需要进行一些配置。首先,需要确保WSL已经正确安装并已启用,可以通过在控制面板中的“程序和功能”中查找“Windows Subsystem for Linux”来确认。 接下来,还需要安装WSL对应的Linux发行版,如Ubuntu或Debian。可以通过在微软商店中搜索并安装相应的Linux发行版。 然后,需要在WSL中启用USB功能。首先,在Windows操作系统中,打开“设置”应用,选择“升级和安全”>“开发者选项”,启用“开发人员模式”。 然后,在WSL中打开一个终端窗口,运行以下命令来更新软件包列表并安装所需的软件包: sudo apt-get update sudo apt-get install usbutils 安装完成后,将USB存储设备连接到计算机,然后在WSL中运行以下命令来检测并识别USB存储设备: lsusb 运行命令后,将会列出连接到计算机的USB设备的信息,包括厂商ID和产品ID等。通过这些信息,可以确认USB存储设备是否已被成功识别。 如果USB存储设备已被正确识别,可以通过WSL中的文件管理器来浏览和访问USB存储设备中的文件和文件夹。 需要注意的是,USB存储设备在WSL中的使用方式可能有一些限制和差异,一些高级功能或特殊设备可能无法在WSL中正常工作。此外,还需要确保已经授予WSL访问USB设备的权限。 总之,通过以上步骤可以在WSL中使用USB Storage,并在WSL中进行文件的读写操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值