ubuntu16.04 安装 libnfc

 

 

1. 安装依赖包

sudo apt-get install libusb-dev dh-autoreconf libusb-0.1.4 pkg-config

注:不安装 pkg-config 会导致 ./congigure 时报错。

 

2. 获取源码

mkdir pn532

cd pn532

git clone https://github.com/nfc-tools/libnfc

 

3. 编译安装

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 。

 

4. 安装第三部后输入 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 decive found

sudo mkdir /usr/local/etc/nfc

sudo cp ~/pn532/libnfc/libnfc.conf.sample /usr/local/etc/nfc/libnfc.conf

将文件 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"

 

 

 

 

    

 

posted @ 2020-01-03 13:04  doitjust  阅读(581)  评论(0编辑  收藏  举报