Do much, Make more

improve and improve.

[NFC] Use Libnfc On Windows

参照Libnfc在Windows下说明文档介绍下部署过程

*-
* Public platform independent Near Field Communication (NFC) library
* Copyright (C) 2010, Glenn Ergeerts
-*

Requirements
============

- MinGW-w64 compiler toolchain [1]
- LibUsb-Win32 0.1.12.2 [2]
- CMake 2.6 [3]

This was tested on Windows 7 64 bit, but should work on Windows Vista and
Windows XP and 32 bit as well. 
Only the ACS ACR122 reader is tested at the moment, so any feedback about other devices is very welcome.

Community forum: http://www.libnfc.org/community/

Building
========

To build the distribution the MinGW Makefiles generator of CMake was used. Here
is an example of how to generate a distribution with the above mentioned
requirements fulfilled (it is assumed the CMake binaries are in the system
path, this is optional during installation of CMake):

- Add the following directories to your PATH : c:\MinGW64\bin;c:\MinGW64\x86_64-w64-mingw32\lib32;c:\MinGW64\x86_64-w64-mingw32\include

- Now it is possible to run CMake and mingw32-make:

  C:\dev\libnfc-read-only> mkdir ..\libnfc-build
  C:\dev\libnfc-read-only> cd ..\libnfc-build
  C:\dev\libnfc-build> cmake-gui .
  
Now you can configure the build. Press "Configure", specify "MinGW32 Makefiles"
and then you have the opportunity to set some configuration variables. If you
don't want a Debug build change the variable CMAKE_BUILD_TYPE to "Release".

If a non-GUI solution is preferred one can use:

  C:\dev\libnfc-build> cmake -G "MinGW Makefiles"
                                     -DCMAKE_BUILD_TYPE=Release ..\libnfc-read-only

Now run mingw32-make to build:

  C:\dev\libnfc-read-only\bin> mingw32-make
  
The build will create a shared library for Windows (nfc.dll) to link your applications against. It will compile
the tools against this shared library. 

References
==========
[1] the easiest way is to use the TDM-GCC installer. 
        Make sure to select MinGW-w64 in the installer, the regular MinGW does not contain headers for PCSC.
        http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm64-gcc-4.5.1.exe/download
[2] http://libusb-win32.sourceforge.net/
[3] http://www.cmake.org

准备条件:

1. Libnfc-x-x-x版本 参见: http://www.libnfc.org/community/

2.MinGW64 ( 注意此处一定得用MingGW-64"TDM64", 官方的文档里已经说明通常的MingGW不带PCSC Header )

3.libusb-win32-bin-x.x.x.x

4.cmake-2.8.6-win32-x86

上面几个工具除了LibNfc源码包我已打包上传: http://download.csdn.net/detail/domy1215/3675361


STEP1 安装相关工具,并配置系统环境变量

1.首先需要安装MingGW64, Libusb及CMake

2.配置相关环境变量,文档里都有: 

c:\MinGW64\bin;c:\MinGW64\x86_64-w64-mingw32\lib32;c:\MinGW64\x86_64-w64-mingw32\include, 另外需要将Libusb安装路径添加进系统变量,并确保Libusb目录下包含Include及Lib文件,另外Check一下System32里是否存在linusb0.dll及winsdcard.dll,编译时需要查找

2.硬件接入PC后使用Libusb手动安装驱动,安装成功后,设备管理器会有相关显示(我的设备使用的是NXP PN533)


STEP2 使用CMake构建工程

1.启动“cmake-gui.exe”,并添加Source Code及工程输出路径,并进行配置工程为MingW MakeFile


此后开始构建工程,其中有可能遇到几个问题:

一是有关PCSC这个便应该是此前所说MingW版本的问题了,标准包不包含PCSC头文件;

二是关于winsdcardd.dll这个比较蹊跷,据说是跟VC有关,详情可参见下帖: http://www.libnfc.org/community/topic/432/installing-libnfc-on-windows-missing-pcsc/

另外建议直接从SVN上Check 最新Truck代码进行编译

OK,工程构建完成


STEP3 编译执行

命令行下进入构建的工程文件夹,调用“mingw32-make”命令进行编译


此处若产生编辑错误就是代码问题了,Open Source and resolve it !


OK了,编译成功,此时进入工程文件夹下Example及Utils文件夹里已生成可执行文件

STEP4 DLL

编译成功后Libnfc下会生成libnfc.dll, Now try to use it...


阅读更多
个人分类: NFC
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭