文档库

最新最全的文档下载
当前位置:文档库 > windows平台使用cmake编译libnfc 1.7.0 rc6全过程

windows平台使用cmake编译libnfc 1.7.0 rc6全过程

windows平台使用cmake编译libnfc 1.7.0 rc6全过程

chenxupro 最近一时兴起,搞nfc,网上多是linux平台编译的详细过程,windows平台说的不多,而有时又需要在win下面使用,于是就将自己的编译过程记录下来。

1.安装tdm64-gcc-4.7.1-3.exe

下载地址http://www.wendangku.net/doc/fe3f51196edb6f1aff001f1d.html/projects/tdm-gcc/files/TDM-GCC%20Installer/

默认选项安装,安装路径C:\MinGW64

2.安装cmake-2.8.10.2-win32-x86.exe

选择Add CMake to the system PATH for all users

安装路径C:\Program Files\CMake 2.8

3.安装libusb-win32-bin-1.2.6.0.zip

下载地址http://www.wendangku.net/doc/fe3f51196edb6f1aff001f1d.html/projects/libusb-win32/files/libusb-win32-releases/

解压到C:\libnfccompile\libusb-win32-bin-1.2.6.0

4.解压libnfc-1.7.0-rc6.tar.gz

解压到C:\libnfccompile\libnfc-1.7.0-rc6

5.cmake生成Makefile

新建一个目录libnfc-1.7.0-build,运行cmd切换目录到C:\libnfccompile\libnfc-1.7.0-build 运行cmake-gui

Where is the source code: C:/libnfccompile/libnfc-1.7.0-rc6

Where to build the binaries: C:/libnfccompile/libnfc-1.7.0-build

CMAKE_INSTALL_PREFIX: C:/Program Files/CMake 2.8

CMAKE_BUILD_TYPE: Release

因为我这里的设备只有USB接口的ACR122U和UART接口的PN532,所以将这两项打勾

LIBNFC_DRIVER_ACR122_PCSC打勾

LIBNFC_DRIVER_PN532_UART打勾

需要的话也可以将LIBNFC_DRIVER_PN53X_USB打勾

勾选Advanced选项可以出现更多的配置选项

点击Configure,选择MinGW Makefiles

报错:Could not find PCRE

解决方法:

从http://www.wendangku.net/doc/fe3f51196edb6f1aff001f1d.html/projects/gnuwin32/files/pcre/下载pcre-7.0-lib.zip

解压至C:\libnfccompile\pcre-7.0-lib

PCRE_INCLUDE_DIRS C:\libnfccompile\pcre-7.0-lib\include

PCRE_LIBRARIES C:\libnfccompile\pcre-7.0-lib\lib

报错:Could NOT find PCSC

参照下面链接的解决方案:

http://www.wendangku.net/doc/fe3f51196edb6f1aff001f1d.html/community/topic/432/installing-libnfc-on-windows-missing-pcsc/ 使用winscard.h和libwinscard.a代替libpcsc

PCSC_INCLUDE_DIRS C:\MinGW64\x86_64-w64-mingw32\include

PCSC_LIBRARIED C:\WINDOWS\system32\winscard.dll

再次Configure会提示:

Found PCSC: C:\WINDOWS\system32\winscard.dll

报错:Could not find LIBUSB

解决方法:

LIBUSB_INCLUDE_DIRS C:\libnfccompile\libusb-win32-bin-1.2.6.0\include

LIBUSB_LIBRARIES C:\libnfccompile\libusb-win32-bin-1.2.6.0\bin\x86\libusb0_x86.dll

报错:Could NOT find Doxygen

解决方法:

下载安装doxygen-1.8.3.1-setup.exe

重新Configure直到显示"Configuring done",然后Generate生成Makefile

6.运行mingw32-make

打开cmd在C:\libnfccompile\libnfc-1.7.0-build目录下运行mingw32-make

报错:C:\MinGW64\bin\windres.exe:

C:\\libnfccompile\\libnfc-1.7.0-build\\windows\\libnfc.rc:26: syntax error

原因:打开libnfc.rc,会发现有如下所示的语句

VALUE "LegalCopyright", "Copyright (C) 2013-04-05 星期五

解决方法:只需这里将中文"星期五"和"\0"之间的换行去掉即可,用同样的方法修改

libnfc-1.7.0-build\windows\目录下的所有.rc文件

报错:undefined reference to 'usb_prepare'

原因:

参考

http://www.wendangku.net/doc/fe3f51196edb6f1aff001f1d.html/community/topic/933/linking-c-shared-lib-libnfcdll-undefined-referenc e-to-usbprepare/

这是1.7.0的rc6代码的bug

修改C:\libnfccompile\libnfc-1.7.0-rc6\libnfc\CMakeLists.txt:

将SET(BUSES_SOURCES buses/uart)改成SET(BUSES_SOURCES buses/uart buses/usbbus)

git clone https://http://www.wendangku.net/doc/fe3f51196edb6f1aff001f1d.html/p/libnfc/ 下载最新的代码也可以解决问题

重新Configure和Generate后运行mingw32-make,成功生成libnfc相关的dll库和测试exe以及工具exe

其他问题可以参考http://www.wendangku.net/doc/fe3f51196edb6f1aff001f1d.html/community/里面的解决方法

在使用ACR122U设备的时候可能会需要安装libusb附带的驱动

位于C:\libnfccompile\libusb-win32-bin-1.2.6.0\bin\inf-wizard.exe