ubuntu安装libnfc
2018-06-22 本文已影响18人
fangqi179
背景
最近想研究下PN532模块,准备在Ubuntu服务器上安装libnfc。
安装步骤
第一步
安装依赖包
sudo apt-get install libusb-dev dh-autoreconf libusb-0.1.4 pkg-config
不安装pkg-config会导致./configure时报错。
第二步
获取源码
cd ~
mkdir pn532
cd pn532
git clone https://github.com/nfc-tools/libnfc
第三步
编译安装
cd libnfc
autoreconf -vis
./configure --with-drivers=pn532_uart --enable-serial-autoprobe --prefix=/usr/local/
sudo make clean all
sudo make
sudo make install
默认情况下,执行【make install】命令后会将包中的命令安装至【/usr/local/bin】中,包含的文件到【/usr/local/include】,其他的类似。也可以在./configure时指定一个绝对地址的前缀,类似这样的--prefix=/PATH_NAME。
第四步
我在第三步安装后输入nfc-list命令会报错:
nfc-list: error while loading shared libraries: libnfc.so.5: cannot open shared object file: No such file or directory
所以我又在网上找了修复方法,如下:
# 第一步
su root
# 第二步
echo "/usr/local/lib" >> /etc/ld.so.conf.d/loc_lib.conf
# 第三步
/sbin/ldconfig
libnfc更新
cd ~/pn532/libnfc
git pull origin master:master
autoreconf -vis
./configure --with-drivers=pn532_uart --enable-serial-autoprobe --prefix=/usr/local/
sudo make clean all
sudo make
sudo make install
解决No NFC device found.
sudo mkdir /usr/local/etc/nfc
sudo cp ~/pn532/libnfc/libnfc.conf.sample /usr/local/etc/nfc/libnfc.conf
将文件内容修改为
# Allow device auto-detection (default: true)
# Note: if this auto-detection is disabled, user has to set manually a device
# configuration using file or environment variable
allow_autoscan = true
# Allow intrusive auto-detection (default: false)
# Warning: intrusive auto-detection can seriously disturb other devices
# This option is not recommended, user should prefer to add manually his device.
#allow_intrusive_scan = false
# Set log level (default: error)
# Valid log levels are (in order of verbosity): 0 (none), 1 (error), 2 (info), 3 (debug)
# Note: if you compiled with --enable-debug option, the default log level is "debug"
log_level = 1
# Manually set default device (no default)
# To set a default device, you must set both name and connstring for your device
# Note: if autoscan is enabled, default device will be the first device available in device list.
device.name = "microBuilder.eu"
device.connstring = "pn532_uart:/dev/ttyUSB0"