![如何安装 libusbx 库](https://linux22.com/image/970132/%E5%A6%82%E4%BD%95%E5%AE%89%E8%A3%85%20libusbx%20%E5%BA%93.png)
我正在努力奔跑闪存工具(为安卓手机刷机的实用程序)在 ubuntu 中。已经设置了 java 和适当的环境
执行时出现以下错误
rajeswar@WebE-PCl:~$ FlashTool/FlashTool
Not running as root but Sony/SonyEriccson Vendor ID found on your udev rules
if Flashing didn't work well, run flashtool as root
libusb.LibUsbException: Libusb not found. Minimum libusb version is 1.0.15. It can be downloaded on http://www.libusbx.org
at libusb.UsbSystem.initSystem(UsbSystem.java:28)
at libusb.UsbSystem.<init>(UsbSystem.java:15)
at linuxlib.JUsb.init(JUsb.java:21)
at gui.Main.initLinuxUsb(Main.java:47)
at gui.Main.main(Main.java:34)
所以我从http://libusbx.org/,执行提取后
./configure && sudo make && sudo make install && sudo ldconfig
。
它成功执行并安装到/usr/local/lib/
..但错误不断出现..
这是输出sudo ldconfig -vp | grep usb
libusbmuxd.so.2 (libc6,x86-64) => /usr/lib/libusbmuxd.so.2
libusb-1.0.so.0 (libc6,x86-64) => /usr/local/lib/libusb-1.0.so.0
libusb-1.0.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libusb-1.0.so.0
libusb-1.0.so (libc6,x86-64) => /usr/local/lib/libusb-1.0.so
libusb-0.1.so.4 (libc6,x86-64) => /lib/x86_64-linux-gnu/libusb-0.1.so.4
libusb-0.1.so.4 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libusb-0.1.so.4
libgusb.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgusb.so.2
知道如何修复它吗?
以下是flashtool启动脚本的内容
#!/bin/sh
export BASEDIR=$(dirname $0)
export system64=$(uname -m)
export OS=$(uname -s)
cd $BASEDIR
if test "$OS" = "Linux"
then
chmod 755 ./x10flasher_lib/adb.linux
chmod 755 ./x10flasher_lib/fastboot.linux
chmod 755 ./x10flasher_lib/unyaffs.linux
chmod 755 ./x10flasher_lib/bin2elf
chmod 755 ./x10flasher_lib/bin2sin
if [ "$(whoami)" != "root" ]
then
export HASRULES="false"
if test -d /etc/udev/rules.d
then
if grep -rl "0fce" /etc/udev/rules.d >/dev/null
then
export HASRULES="true"
fi
fi
if test "$HASRULES" = "true"
then
echo "Not running as root but Sony/SonyEriccson Vendor ID found on your udev rules"
echo "if Flashing didn't work well, run flashtool as root"
else
echo "Not running as root and there is no Sony/SonyEriccson Vendor ID on your udev rules"
echo "The user must be granted access to adb/flashmode/fastboot"
echo "If you are unsure what to do, run flashtool as root"
exit 1
fi
else
echo "Running as root."
fi
if test -z "${JAVA_HOME}"
then
if test "${system64}" = "x86_64"
then
export JAVA_HOME=./x10flasher_lib/linjre64
else
export JAVA_HOME=./x10flasher_lib/linjre32
fi
echo "JAVA_HOME not set. Using default value : ${JAVA_HOME}"
fi
if test -e ${JAVA_HOME}/bin/java
then
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib32
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib64:$LD_LIBRARY_PATH
ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so
ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib64/libusbx-1.0.so
ISJAVA6=$($JAVA_HOME/bin/java -version 2>&1|grep version|grep 1.6|wc -l)
ISJAVA7=$($JAVA_HOME/bin/java -version 2>&1|grep version|grep 1.7|wc -l)
ISJAVA64=$($JAVA_HOME/bin/java -version 2>&1|grep 64-Bit|wc -l)
if test $ISJAVA6 -gt 0 -o $ISJAVA7 -gt 0
then
if test $ISJAVA64 -gt 0
then
ln -sf swt64.jar ./x10flasher_lib/swtlin/swt.jar
else
ln -sf swt32.jar ./x10flasher_lib/swtlin/swt.jar
fi
$JAVA_HOME/bin/java -Xms128m -Xmx512m -Duser.country=US -Duser.language=en -jar x10flasher.jar
else
echo "Java version must be 1.6 or 1.7"
fi
else
echo "No Java in specified path in JAVA_HOME=${JAVA_HOME}"
echo "Set the variable to a valid Java installation"
fi
else
chmod 755 ./x10flasher_lib/adb.mac
chmod 755 ./x10flasher_lib/fastboot.mac
chmod 755 ./x10flasher_lib/unyaffs.mac
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib64:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib32:$DYLD_LIBRARY_PATH
ln -sf libusbx-1.0.0.dylib ./x10flasher_lib/mac/lib64/libusbx-1.0.dylib
ln -sf libusbx-1.0.0.dylib ./x10flasher_lib/mac/lib32/libusbx-1.0.dylib
ISJAVA6=$(java -version 2>&1|grep version|grep 1.6|wc -l)
ISJAVA7=$(java -version 2>&1|grep version|grep 1.7|wc -l)
ISJAVA64=$(java -version 2>&1|grep 64-Bit|wc -l)
if test $ISJAVA64 -gt 0
then
ln -sf swt64.jar ./x10flasher_lib/swtmac/swt.jar
else
ln -sf swt32.jar ./x10flasher_lib/swtmac/swt.jar
fi
if test $ISJAVA6 -gt 0 -o $ISJAVA7 -gt 0
then
java -XstartOnFirstThread -Xms128m -Xmx512m -Duser.country=US -Duser.language=en -jar x10flasher.jar
else
echo "Java version must be 1.6 or 1.7"
fi
fi
我认为问题出在这些方面
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib32
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib64:$LD_LIBRARY_PATH
ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so
ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib64/libusbx-1.0.so
答案1
刚刚找到解决方案。添加以供将来参考
复制/usr/local/lib/libusb-1.0.so.0.1.0
到FlashTool/x10flasher_lib/linux/lib64
和FlashTool/x10flasher_lib/linux/lib32
。
在 Flashtool 脚本中搜索以下几行
ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so
ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib64/libusbx-1.0.so
将其更改为
ln -sf libusb-1.0.so.0.1.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so
ln -sf libusb-1.0.so.0.1.0 ./x10flasher_lib/linux/lib64/libusbx-1.0.so
现在运行 flashtool,您就可以开始了。
笔记:
如果之前出现JAVA_HOME NOT SET
错误,请执行以下操作
这将为所有用户设置变量
sudo gedit /etc/profile.d/java.sh
如果您安装了 oracle jdk,请粘贴,如果您使用的是 open jdk,请进行相应更改
export JDK_HOME=/usr/lib/jvm/java-7-oracle
export JAVA_HOME=/usr/lib/jvm/java-7-oracle
然后在终端运行:
sudo chmod +x /etc/profile.d/java.sh
source /etc/profile.d/java.sh
如果在 flashtool GUI 出现后出现cannot open shared library libncurses.so.5
,请安装 32 位版本的库
sudo apt-get install lib32ncurses5