背景
最近想研究下PN532模塊,準(zhǔn)備在Ubuntu服務(wù)器上安裝libnfc。
安裝步驟
第一步
安裝依賴包
sudo apt-get install libusb-dev dh-autoreconf libusb-0.1.4 pkg-config
不安裝pkg-config會(huì)導(dǎo)致./configure時(shí)報(bào)錯(cuò)绵载。
第二步
獲取源碼
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
默認(rèn)情況下,執(zhí)行【make install】命令后會(huì)將包中的命令安裝至【/usr/local/bin】中,包含的文件到【/usr/local/include】学搜,其他的類似。也可以在./configure時(shí)指定一個(gè)絕對地址的前綴论衍,類似這樣的--prefix=/PATH_NAME瑞佩。
第四步
我在第三步安裝后輸入nfc-list命令會(huì)報(bào)錯(cuò):
nfc-list: error while loading shared libraries: libnfc.so.5: cannot open shared object file: No such file or directory
所以我又在網(wǎng)上找了修復(fù)方法,如下:
# 第一步
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
將文件內(nèi)容修改為
# 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"