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 25 April 2014: Google has changed the way direct downloads work on Google Code. To manually download the archived source files, go to the following URL and select 'download .tar.gz': https://code.google.com/p/libnfc/source/browse/?name=libnfc-1.7.0
$ cd /home/pi
$ mkdir libnfc
$ cd libnfc
$ wget https://libnfc.googlecode.com/archive/libnfc-1.7.0.tar.gz
$ tar -xvzf libnfc-1.7.0.tar.gz
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-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 ...
Last updated on 2015-05-04 at 04.27.56 PM Published on 2012-07-29 at 11.58.37 AM