Linux下编译安装libnfc

     最近从朋友那里借来了两块PN532板子玩,在电脑上编译安装libnfc的时候大费周折,泡了将近一天的坛子,终于安装成功了,这里把这个安装过程记录了一下。

首先安装编译需要的库

$ sudo apt-get install libusb-dev libpcsclite-dev libusb-0.1-4 libpcsclite1 libccid pcscd

下载libnfc源码包

可以到google code下载官方包(https://code.google.com/p/libnfc/downloads/list),不过貌似google code在国内用不是很稳定,我下了n多次才下好,把它传到百度网盘上(http://pan.baidu.com/s/1sjCVliX

解压、配置、安装

$ tar -xvzf libnfc-1.7.0-rc7.tar.gz
$ cd libnfc-1.7.0-rc7$ ./configure --with-drivers=pn532_uart
$ make
$ make install

安装完成后验证安装是否成功:

将PN532插入PC USB接口运行nfc-list示例程序
$ sudo nfc-list
出现以下信息则表示安装成功:

nfc-list uses libnfc 1.7.0-rc7                              
NFC device: pn532_uart:/dev/ttyUSB0 opened

如果显示:

情况一:

No NFC device found.

则安装失败,这时候请检查/usr/local/etc/目录下是否有nfc文件夹。如果没有,请在/usr/local/etc/目录下新建nfc文件夹,然后在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_autoscan = true
# 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 = debug
# 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/ttyAMA0"
device.connstring = "pn532_uart:/dev/ttyUSB0"

保存退出后再次尝试,问题解决。

情况二:

nfc-list: error while loading shared libraries: libnfc.so.4: cannot open shared object file: No such file or directory

打开终端执行如下命令

# sudo su
# echo "/usr/local/lib" >> /etc/ld.so.conf.d/loc_lib.conf
# /sbin/ldconfig

我暂时就遇到了这两个问题,其他的问题我从网上找了些资料,大家可自行参阅。问题汇集


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值