Building libnfc

Step One: Download libnfc

Before you can do anything, you will need to get a copy of libnfc. Make sure you have an Ethernet cable connected to your Pi, and run the following commands to get libnfc 1.7.0
UPDATE 22 Jan 2018: LIBNFC has moved to Github, and 1.7.0 can be downloaded directly from this URL: https://github.com/nfc-tools/libnfc/releases/tag/libnfc-1.7.0
$ cd /home/pi
$ mkdir libnfc
$ cd libnfc
$ wget https://github.com/nfc-tools/libnfc/releases/download/libnfc-1.7.0/libnfc-1.7.0.tar.bz2
$ tar -xvjf libnfc-1.7.0.tar.bz2
You should see something similar to the following:

Step Two: Setup libnfc for the Pi

Before libnfc can be built, it needs to be configured for the target system and based on some parameters specific the NFC device you have connected.

libnfc 1.7.0 and later use a new config file, which needs to be placed at a specific location. Thankfully, libnfc 1.7.0 includes a config file for the Raspberry Pi, which you can copy to the right destination with the following commands:
$ cd libnfc-1.7.0
$ sudo mkdir /etc/nfc
$ sudo mkdir /etc/nfc/devices.d
$ sudo cp contrib/libnfc/pn532_uart_on_rpi.conf.sample /etc/nfc/devices.d/pn532_uart_on_rpi.conf
Next, we need to make a small change to this file, which we can do by entering:
sudo nano /etc/nfc/devices.d/pn532_uart_on_rpi.conf
Update the file to include the following line at the bottom:
allow_intrusive_scan = true

Press CTRL+O then enter to save the file, and then CTRL+X to quite nano.

Step Three: Run Config

The next step is to configure the project itself using the 'configure' tool, as follows:
$ sudo apt-get install autoconf
$ sudo apt-get install libtool
$ sudo apt-get install libpcsclite-dev libusb-dev
$ autoreconf -vis
$ ./configure --with-drivers=pn532_uart --sysconfdir=/etc --prefix=/usr
This should give you the following screen once the configuration process is complete (it takes a few minute though):

Step Four: Build!

To build libnfc, you simply need to enter the following commands:
$ sudo make clean
$ sudo make install all
Which should start the (slowish!) build process as follows:
Once the build process is complete, you're ready to go on to testing the library on actual HW ...
This guide was first published on Jul 29, 2012. It was last updated on Oct 14, 2018. This page (Building libnfc) was last updated on Jan 22, 2018.