0

I am on windows 8 64 bits.

I have installed successfully libnfc, and I am able to use the .exe examples that are in libnfc\utils (like nfc-mfclassic.exe; nfc-list.exe ...)

I would like to manipulate Mifare cards and use NDEF Format, so I am trying to install libfreefare on Windows.

I have followed a tutorial on libnfc.org showing how to have libfreefare on Windows and It worked fine.

And I used cmake-gui to generate build file

Coming now to the step of mingw32-make, I have this error :

[ 55%] Building C object libfreefare/CMakeFiles/freefare.dir/tlv.c.obj
Linking C shared library libfreefare.dll
CMakeFiles\freefare.dir/objects.a(mifare_desfire.c.obj):mifare_desfire.c:(.text+0x64f): undefined reference to `RAND_bytes'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_crypto.c.obj):mifare_desfire_crypto.c:(.text+0x1219): undefined reference to `DES_ecb_encrypt'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_crypto.c.obj):mifare_desfire_crypto.c:(.text+0x1242): undefined reference to `DES_ecb_encrypt'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_crypto.c.obj):mifare_desfire_crypto.c:(.text+0x1280): undefined reference to `DES_ecb_encrypt'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_crypto.c.obj):mifare_desfire_crypto.c:(.text+0x12a9): undefined reference to `DES_ecb_encrypt'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_crypto.c.obj):mifare_desfire_crypto.c:(.text+0x12d0): undefined reference to `DES_ecb_encrypt'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_crypto.c.obj):mifare_desfire_crypto.c:(.text+0x12f9): more undefined references to `DES_ecb_encrypt' follow
CMakeFiles\freefare.dir/objects.a(mifare_desfire_crypto.c.obj):mifare_desfire_crypto.c:(.text+0x1489): undefined reference to `AES_set_encrypt_key'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_crypto.c.obj):mifare_desfire_crypto.c:(.text+0x14a8): undefined reference to `AES_encrypt'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_crypto.c.obj):mifare_desfire_crypto.c:(.text+0x14c7): undefined reference to `AES_set_decrypt_key'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_crypto.c.obj):mifare_desfire_crypto.c:(.text+0x14e6): undefined reference to `AES_decrypt'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_key.c.obj):mifare_desfire_key.c:(.text+0x17): undefined reference to `DES_set_key'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_key.c.obj):mifare_desfire_key.c:(.text+0x32): undefined reference to `DES_set_key'
CMakeFiles\freefare.dir/objects.a(mifare_desfire_key.c.obj):mifare_desfire_key.c:(.text+0x58): undefined reference to `DES_set_key'
CMakeFiles\freefare.dir/objects.a(mifare_ultralight.c.obj):mifare_ultralight.c:(.text+0x7a3): undefined reference to `DES_random_key'
collect2.exe: error: ld returned 1 exit status
libfreefare\CMakeFiles\freefare.dir\build.make:351: recipe for target 'libfreefare/libfreefare.dll' failed
mingw32-make[2]: *** [libfreefare/libfreefare.dll] Error 1
CMakeFiles\Makefile2:74: recipe for target 'libfreefare/CMakeFiles/freefare.dir/all' failed
mingw32-make[1]: *** [libfreefare/CMakeFiles/freefare.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Thanks for your help !!

wald
  • 93
  • 1
  • 2
  • 9
  • 1
    It seems to me: 1. you may have not included a file in the compilation which has the definitions of the above undefined variables; 2. you may have included the file in your program but it is not mentioned in the Makefile file paths for your compiler to find. Could you first search in your file where the above variables are mentioned then check if the file they are included in is present as a #include or if the file path is in one of the Makefile paths – Peter Feb 18 '15 at 10:42
  • Do you have a compatible version of OpenSSL and did you properly link to libcrypto? – Michael Roland Feb 18 '15 at 11:25
  • @Peter I have found out that in `mifare_desfire.c` there is `#include ` so i thought it was a path problem then I changed it for `#include ` but it didn't work. In the directory containing `mifare_desfire.c` there is CMakeLists.txt I added `include_directories(D:\\tools\\OpenSSL-Win64\\include)` but didn't work, is there a way to indicate additionnal include directory ? – wald Feb 18 '15 at 19:07
  • @MichaelRoland I've `Win64OpenSSL-1_0_1L.exe` from here [link](http://slproweb.com/products/Win32OpenSSL.html)[/link] I don't think I linked it to libcryto i don't have it in the OpenSSL distribution. I've libssl32.dll can I use this one at the place ? – wald Feb 18 '15 at 19:24
  • 1
    @wald See this question: [Win7 OpenSSL libcrypto equivalent missing](http://stackoverflow.com/q/19321982/2425802) – Michael Roland Feb 18 '15 at 19:27
  • @MichaelRoland how do you link to libcrypto please? – wald Feb 18 '15 at 19:42
  • I'm not familiar with your toolchain, so I don't really know (otherwise I would have provided an answer). I would expect that you either have a Makefile where you define the libraries that should be included during linking. This is typically in a parameter named LDFLAGS or LIBS, where you would need to add "-llibeay32" – Michael Roland Feb 18 '15 at 19:59
  • Having myself failed to compile libnfc more than two times, would you kindly add which instructions you followed and where did you download compiler, libusb and of course libnfc – Stefano Mtangoo Feb 02 '16 at 20:14

1 Answers1

1

I've found a solution :

At the root of the folder : libfreefare-0.4.0 there is CMakeLists.txt

I replaced this line :

set(LIBS ${LIBS} ${LIBNFC_LIBRARIES} ${OPENSSL_LIBRARIES})

by this one

set(LIBS ${LIBS} ${LIBNFC_LIBRARIES} D:/tools/OpenSSL-Win32/libeay32.dll D:/tools/OpenSSL-Win32/libssl32.dll)

And it worked fine ! Thanks @MichaelRoland for the tips on libcrypto equivalent

wald
  • 93
  • 1
  • 2
  • 9