Update README-Windows.md

Updated with working instructions for building on windows
This commit is contained in:
Ben 2017-10-15 14:49:02 -06:00 committed by GitHub
parent a72f41a109
commit e32f33eee5

View File

@ -1,70 +1,70 @@
*- ## Compile for Windows - 64-BIT (x64)
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* Additional contributors of Windows-specific parts:
* Copyright (C) 2010 Glenn Ergeerts
* Copyright (C) 2013 Alex Lian
-*
Requirements #### Tested using windows 10 pro x64, build 1703.
============
- MinGW-w64 compiler toolchain [1] Install latest libusbk release from: (this installs both libusb and libusbk windows components required for running libnfc applications)
- LibUsb-Win32 1.2.5.0 (or greater) [2] https://sourceforge.net/projects/libusb-win32/files/libusbK-release/
- CMake 2.8 [3] https://sourceforge.net/projects/libusb-win32/files/libusbK-release/libusbK-3.0.7.0-setup.exe
This was tested on Windows 7 64 bit, but should work on Windows Vista and #### install mingw64 toolchain on Windows:
Windows XP and 32 bit as well.
Only the ACS ACR122 and the ASK Logo readers are tested at the moment, so any feedback about other devices is very welcome.
Community forum: http://www.libnfc.org/community/ ##### Install latest version of: MSYS2 for 64-bit windows.
##### even if msys2 version appears old, the packages it installs are very recent:
http://www.msys2.org/
msys2-x86_64-xxxxxxxx.exe
Building
========
To build the distribution the MinGW Makefiles generator of CMake was used. Here ##### Open the MSYS shell in mingw-64 mode (64-bit mode)
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 #update the MSYS system using pacman:
path, this is optional during installation of CMake): pacman -Syu
- Add the following directories to your PATH: #close the shell, re-open and run:
pacman -Su
c:\MinGW64\bin;c:\MinGW64\x86_64-w64-mingw32\lib32;c:\MinGW64\x86_64-w64-mingw32\include #install build tools:
pacman -S git make mingw-w64-$(uname -m)-gcc mingw-w64-$(uname -m)-binutils mingw-w64-$(uname -m)-cmake mingw-w64-$(uname -m)-zlib mingw-w64-$(uname -m)-make
```
- Now it is possible to run CMake and mingw32-make: #### download and extract: libusb-win32-bin-1.2.6.0.zip
##### todo: (this step shouldn't be needed, as libusb0.dll is already in system32, but the logic is broken in the libusb search that cmake uses in: cmake/modules/FindLIBUSB.cmake, so do this step for now)
https://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/
##### Extract contents to the native program files directory: (not the x86 program files!):
C:\Program Files\libusb-win32
C:\dev\libnfc-read-only> mkdir ..\libnfc-build #### Restart msys2 bash - in mingw-64 mode.
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: #download libnfc source files:
cd ~
mkdir libnfc-build-win64
git clone https://github.com/nfc-tools/libnfc.git
C:\dev\libnfc-build> cmake -G "MinGW Makefiles" # launch windows powershell x64 (non-admin)
-DCMAKE_BUILD_TYPE=Release ..\libnfc-read-only # add some paths for current build session:
Now run mingw32-make to build: $env:Path += ";c:\msys64\mingw64\bin;c:\msys64\mingw64\x86_64-w64-mingw32\lib;c:\msys64\mingw64\x86_64-w64-mingw32\include"
cd C:\msys64\home\<your username>\libnfc-build-win64
C:\dev\libnfc-read-only\bin> mingw32-make #then, run "CMD.exe" from within the powershell, (this ensures the PATH set above is available in the build environment)
cmd.exe
The build will create a shared library for Windows (nfc.dll) to link your applications against. It will compile # configure the build with cmake:
the tools against this shared library. cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ..\libnfc
References # run cmake again, same parameters, otherwise errors appear:
========== cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ..\libnfc
[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://sourceforge.net/projects/libusb-win32/files/ # build it!
mingw32-make
```
#### put your "libnfc.conf" into c:\program files (x86)\libnfc\config\libnfc.conf
todo: it is the wrong location currently for a x64 system, but it works and this will be fixed to use c:\programdata\libnfc\config\libnfc.conf at some point.
#### put compiled DLL file to the real system32 directory: (c:\windows\sysnative\libnfc.dll on syswow64 machines)
copy .\libnfc\libnfc.dll c:\windows\system32\libnfc.dll
#### Run the executables found in libnfc\utils or libnfc\examples
[3] http://www.cmake.org