Online Store

LibNFC Installation on Windows

Installing LibNFC on Windows 8.1

First, download the Zadig USB installer at http://zadig.akeio.ie

Install PN533 reader with libusb0 driver. If the reader is not shown, go to Options-> List All devices.

libNFC1

Now, we have to install LibNFC. Thanks to an article published at MobileFish (http://www.mobilefish.com/developer/LibNFC/LibNFC.html) we can make this process very easy. This is just an updated version of the previously mentioned article.

Operating system used: Windows 8.1 Professional x64

Hardware: Core i5, 8 GB RAM, 64-bit OS

Software prerequisites:

  • TDM-GCC MinGW Compiler
  • libusb-win32
  • PCRE for Windows
  • CMake
  • Doxygen

Installation procedure #

Install TDM-GCC MinGW Compiler #

Go to http://sourceforge.net/projects/tdm-gcc/ and download the TDM-GCC MinGW Compiler.
For example tdm64-gcc-4.8.1-3.exe

Double click the executable and press the Create button.

libNFC2

Select MinGW-w64/TDM64 Experimental (32-bit and 64-bit) and press the Next button.

Note: You need to install this version instead of MinGW/TDM (32 bit). The MinGW-w64/TDM64 version will run on 32-bit and 64-bit operating systems.

libNFC3

Select the TDM-GCC installation directory, for example, C:\tools\MinGW64, and press the Next button.

libNFC

Select your nearest TDM-GCC download server and press the Next button.

 

libNFC5

Choose TDM-GCC Recommended, All Packages, and press the Install button.

libNFC

Wait until TDM-GCC is installed and press the Next button.

 

libNFC

For more information needed about TDM-GCC, read the README-gcc-tdm64.txt file.

Install libusb-win32 #

Go to http://sourceforge.net/projects/libusb-win32/ and download libusb-win32.
For example libusb-win32-bin-1.2.6.0.zip
More information about this library: http://sourceforge.net/apps/trac/libusb-win32/wiki

Download and unzip the file, for example: C:\tools\libusb-win32-bin-1.2.6.0
No further action is required.

Install PCRE for Windows #

Go to http://sourceforge.net/projects/gnuwin32/files/pcre/7.0/ and download the PCRE setup wizard (Perl-compatible regular expression).
For example the pcre-7.0.exe
More information about PCRE: http://www.pcre.org

Double click the executable and press the Next button.

libNFC

Accept the agreement and press the Next button.

libNFC

Select the PCRE installation directory, for example, C:\tools\GnuWin32, and press the Next button.

libNFC

Select Full installation and press the Next button.

libNFC

Enter the PCRE shortcut in the Start menu and press the Next button.

Select additional tasks to be performed and press the Next button.

Press the Install button.

libNFC

Press the Finish button.

libNFC

Install CMake #

Go to http://www.cmake.org/ and download CMake binary distribution for the Windows platform (Win32 Installer). CMake is a cross-platform, open-source build system.
For example the cmake-3.0.1-win32-x86.exe

Double click the executable and press the I Agree button.

libNFC

libNFC

Select Add CMake to the system PATH for all users and press the Next button.

libNFC

Select the CMake installation directory, for example, C:\tools\CMake, and press the Next button.

Choose the start menu folder and press the Install button.

libNFC

Wait until CMake is installed and press the Next button.

libNFC

Press the Finish button to complete the CMake setup.

libNFC

Install Doxygen #

Go to http://www.doxygen.org/ and download Doxygen.
For example the doxygen-1.8.7-setup.exe

Double click the executable and press the Next button.

libNFC

Accept the agreement and press the Next button.

libNFC

Select the Doxygen installation directory, for example, C:\tools\doxygen, and press the Next button.

libNFC

Select Full installation and press the Next button.

libNFC

Enter the Doxygen shortcut in the Start menu and press the Next button.

libNFC

Press the Install button.

libNFC

Doxygen is installing.

libNFC

Read Doxygen information and press the Next button.

libNFC

Press the Finish button.

libNFC

Install LibNFC #

Go to https://bintray.com/nfc-tools/sources/LibNFC and download the free Near Field Communication library (LibNFC).
For example: LibNFC-1.7.1.tar.bz2 

Unpack the file.
For example: C:\tools\LibNFC-1.7.1

More information about this library: http://nfc-tools.org

Set Windows System Path #

Go to System -> Advanced System settings -> Environment Variables

In the System variables, the subwindow selects the variable Path and press the Edit… button.

Edit your System variable Path. Add the following paths (if they were not already created) at the end:

  • C:\tools\doxygen\bin;
  • C:\tools\TDM-GCC-64\bin;
  • C:\tools\TDM-GCC-64\x86_64-w64-mingw32\lib32;
  • C:\tools\ TDM-GCC-64\x86_64-w64-mingw32\include;
  • C:\tools\CMake\bin;
  • C:\tools\GnuWin32\bin;

To test if all required software/libraries are installed and the System PATH is set correctly, open a Dos window and type: cmake.

You should get the result as shown below:

Configure CMake LibNFC project #

  • Create a folder LibNFC-build.
    For example: c:\LibNFC-build
  • Open a dos window and goto the folder LibNFC-build.
    Type command cmake-gui. CMake is used to configure and generate build files for software projects.
    The basic steps for configuring a project are as follows:

    • Select the source directory for the project.
      This should contain the CMakeLists.txt files for the project.
      In this tutorial, the LibNFC source directory is: C:\tools\LibNFC-1.7.1
    • Select the build directory for the project.
      This is the directory where the project will be built.
      It can be the same or a different directory than the source directory.
      For easy cleanup, a separate build directory is recommended.
      CMake will create the directory if it does not exists.
      In this tutorial, the build directory is: c:\LibNFC-build.

 

libNFC

Once the source and binary directories are selected, it is time to press the Configure button.
A window will open:

  • Select the MinGW Makefiles generator.
  • Select option: Use default native compilers.
  • Press the Finish button.

libNFC

This will cause CMake to read all of the input files and discover all the variables used by the project. The first time a variable is displayed, it will be in Red. Users should inspect red variables making sure the values are correct.
For some projects the Configure process can be iterative, so continue to press the Configure button until there are no red entries.

libNFC

You have to point to PCRE include and lib directories and for libusb include and lib directories.

To fix other errors:

Click on the PCRE_INCLUDE_DIRS value and goto:C:\tools\GnuWin32\include

Click on the PCRE_LIBRARIES value and select file:C:\tools\GnuWin32\lib\libpcre.dll.a

Press the Configure button again.

Click on the LIBUSB_INCLUDE_DIRS value and goto:C:\tools\libusb-win32-bin-1.2.6.0\include

Click on the LIBUSB_LIBRARIES value and select file:C:\tools\libusb-win32-bin-1.2.6.0\lib\gcc\libusb.a

With the above, you are building a 32bit application.

For a 64bit system, either a 32bit application or a 64bit application will work. 64bit application can not work on 32bit Windows OS. For a 64bit system, you need to use a 64bit driver.
A 32bit driver will not work under a 64-bit system, and vice versa, a 64bit driver will not work under the 32bit system.

32bit MinGW GCC -libusb-win32-bin-1.2.6.0\lib\gcc\libusb.a

64bit MinGW GCC -directly link to libusb0.dll or create your own import lib . Under LibNFC 1.7.1 libusb.a is correct option.

32bit MSVC (=Microsoft Visual C++) -libusb-win32-bin-1.2.6.0\lib\msvc\libusb.lib

64bit MSVC -libusb-win32-bin-1.2.6.0\lib\msvc_x64\libusb.lib

64bit MSVC for IA64 -libusb-win32-bin-1.2.6.0\lib\msvc_i64\libusb.lib

Borland C (32bit only) -libusb-win32-bin-1.2.6.0\lib\bcc\libusb.lib

Other compiler, use dynamic -libusb-win32-bin-1.2.6.0\lib\dynamic\libusb_dyn.c

Press the Configure button again.

Finally, you will get the screen with no errors.

libNFC

Make sure that LibNFC_DRIVER_PN53X_USB is checked in order PN533 USB NFC stick to work properly!

Click the Configure button and then the Generate button.
This will create files to the build directory: c:\LibNFC-build

Build windows executable files and LibNFC.dll with mingw32-make #

Goto folder C:\LibNFC-build and type: mingw32-make

 

libNFCIt’s DONE!

TESTING #

Finally, you can test LibNFC with the “nfc-list” or “nfc-list –v” command in the command prompt.

libNFC

libNFC

This is the output of the MIFARE® 1K card on the PN533 USB NFC stick.

Scroll Up