Topic: [SOLVED] Mingw problem with makefile libnfc 1.4.2

Hello,

I am having trouble building the library. i have Win7 64bits.

I use all the programs recommended in the readme.txt. (Mingw64 path, etc...)

I explain my problem:

I downloaded libnfc version 1.4.2.

I run the application cmake 2.8.6

I put in configuration: Specify the generator for this project -> MinGW Makefiles and I select: use default native compilers.

Then I click on configure on the main page of the application.

It displays multiple red lines:

he asks me to specify the file to include libusb, I do.

he asks me to specify the library file,

I do it: \ libusb-win32-bin-1.2.5.0 \ lib \ gcc \ libusb.a

Then I click configure again and then everything is ok = Configuring done.

I click on generate = Generating done.

Then, I check it has generated and I see several files and multiple files.

I open the cmd window.

I type the path to the folder where cmake put all the files.

I type the command mingw32-make.

and I have some errors:

C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.4.2\DLL>mingw32-make
Scanning dependencies of target nfc
[  4%] Building C object libnfc/CMakeFiles/nfc.dir/nfc.c.obj
In file included from C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.4.2\libn
fc\drivers.h:37:0,
                 from C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.4.2\libn
fc\nfc.c:42:
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.4.2\libnfc\drivers/pn53x_usb.h
:32:3: error: unknown type name 'usb_dev_handle'
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.4.2\libnfc\drivers/pn53x_usb.h
:39:32: warning: 'struct usb_device' declared inside parameter list [enabled by
default]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.4.2\libnfc\drivers/pn53x_usb.h
:39:32: warning: its scope is only this definition or declaration, which is prob
ably not what you want [enabled by default]
mingw32-make[2]: *** [libnfc/CMakeFiles/nfc.dir/nfc.c.obj] Error 1
mingw32-make[1]: *** [libnfc/CMakeFiles/nfc.dir/all] Error 2
mingw32-make: *** [all] Error 2

C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.4.2\DLL>

I'm not sure of exactly what to do.

I hope someone could help me.
I think I have given much information.

thank you

EDIT :

I managed to get a file libnfc.dll.

I had to deselect LIBNFC_DRIVER_PN533_USB.

I would like to still be able to fully compile the library to use a PN533.

For now I have a ACR122U.

Someone an idea?

Last edited by GGelec (2011-12-08 16:58:59)

Re: [SOLVED] Mingw problem with makefile libnfc 1.4.2

I have a question.

if I want to use libnfc with visual studio 2010.

How to set up Cmake?

Specify the generator for this project?

Visual Studio 10 or MinGW Makefiles?

When I specify Visual Studio 2010, I request two things I can not find.

PCSC_INCLUDE-DIRS:

c: / MinGW64/x86_64-w64-mingw32/include

and

PCSC_LIBRARIES:?? I can not find this.

In cases of MinGW or visual studio 2010 i don't know what type of files / folders i need to specify.

thank you to tell me exactly which.

Thank you for helping me.

Last edited by GGelec (2011-12-09 09:56:50)

Re: [SOLVED] Mingw problem with makefile libnfc 1.4.2

Hi GGelec,

Unfortunately MSVC compiler does not support C99 so it is not possible to compile libnfc with MSVC, you need to use mingw on windows.
The README-Windows.txt file explains how to compile libnfc on windows with mingw

regards, glenn

Re: [SOLVED] Mingw problem with makefile libnfc 1.4.2

glenn wrote:

Hi GGelec,

Unfortunately MSVC compiler does not support C99 so it is not possible to compile libnfc with MSVC, you need to use mingw on windows.
The README-Windows.txt file explains how to compile libnfc on windows with mingw

regards, glenn

Thank you for the answer.

I followed the steps in the Readme.txt.

But I will explain them here to be sure.

I selected configuration = Mingw makefile

I click on configure.

Then I have to specify LIBUSB_INCLUDE_DIRS = C: / Users/UCS3/Desktop/NFC/library/tools/libusb-win32-bin-1.2.5.0/include

Then I have to specify LIBUSB_LIBRARIES = C: / Users/UCS3/Desktop/NFC/library/tools/libusb-win32-bin-1.2.5.0/lib/gcc/libusb.a

I click on configure and generate =

Found libusb: C: / Users/UCS3/Desktop/NFC/library/tools/libusb-win32-bin-1.2.5.0/lib/gcc/libusb.a C: / Users/UCS3/Desktop/NFC/library/tools / libusb-win32-bin-1.2.5.0/include
Configuring done
Generating done

Then, I type "mingw32-make" and then I have some errors:

C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\DLL>mingw32-make
Scanning dependencies of target nfc
[  3%] Building C object libnfc/CMakeFiles/nfc.dir/nfc.c.obj
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\nfc.c: In function
'nfc_connect':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\nfc.c:97:3: warning
: statement with no effect [-Wunused-value]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\nfc.c:119:3: warnin
g: statement with no effect [-Wunused-value]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\nfc.c: In function
'nfc_disconnect':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\nfc.c:139:5: warnin
g: statement with no effect [-Wunused-value]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\nfc.c: In function
'nfc_list_devices':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\nfc.c:157:3: warnin
g: statement with no effect [-Wunused-value]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\nfc.c:168:3: warnin
g: statement with no effect [-Wunused-value]
[  7%] Building C object libnfc/CMakeFiles/nfc.dir/nfc-device.c.obj
[ 11%] Building C object libnfc/CMakeFiles/nfc.dir/nfc-emulation.c.obj
[ 14%] Building C object libnfc/CMakeFiles/nfc.dir/nfc-internal.c.obj
[ 18%] Building C object libnfc/CMakeFiles/nfc.dir/iso14443-subr.c.obj
[ 22%] Building C object libnfc/CMakeFiles/nfc.dir/mirror-subr.c.obj
[ 25%] Building C object libnfc/CMakeFiles/nfc.dir/drivers/acr122.c.obj
[ 29%] Building C object libnfc/CMakeFiles/nfc.dir/drivers/pn53x_usb.c.obj
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\pn53x_usb.c
: In function 'pn53x_usb_init':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\pn53x_usb.c
:659:78: warning: ISO C99 requires rest arguments to be used [enabled by default
]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\pn53x_usb.c
:669:74: warning: ISO C99 requires rest arguments to be used [enabled by default
]
[ 33%] Building C object libnfc/CMakeFiles/nfc.dir/drivers/arygon.c.obj
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\arygon.c: I
n function 'arygon_tama_send':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\arygon.c:28
4:69: warning: ISO C99 requires rest arguments to be used [enabled by default]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\arygon.c: I
n function 'arygon_tama_receive':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\arygon.c:31
7:11: warning: assignment discards 'volatile' qualifier from pointer target type
[enabled by default]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\arygon.c: I
n function 'arygon_firmware':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\arygon.c:43
5:89: warning: ISO C99 requires rest arguments to be used [enabled by default]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\arygon.c:44
0:93: warning: ISO C99 requires rest arguments to be used [enabled by default]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\arygon.c: I
n function 'arygon_reset_tama':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\drivers\arygon.c:47
1:83: warning: ISO C99 requires rest arguments to be used [enabled by default]
[ 37%] Building C object libnfc/CMakeFiles/nfc.dir/buses/uart.c.obj
In file included from C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libn
fc\buses\uart.c:41:0:
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\buses\uart_win32.c:
In function 'uart_receive':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\buses\uart_win32.c:
159:87: warning: ISO C99 requires rest arguments to be used [enabled by default]

C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\buses\uart_win32.c:
168:58: warning: ISO C99 requires rest arguments to be used [enabled by default]

C:/Users/UCS3/Desktop/NFC/library/Source/libnfc-1.5.1/contrib/win32/err.h:17:13:
warning: unused variable 'errx' [-Wunused-variable]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\buses\uart_win32.c:
In function 'uart_send':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\buses\uart_win32.c:
209:87: warning: ISO C99 requires rest arguments to be used [enabled by default]

[ 40%] Building C object libnfc/CMakeFiles/nfc.dir/chips/pn53x.c.obj
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\chips\pn53x.c: In f
unction 'pn53x_check_ack_frame':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\chips\pn53x.c:2372:
63: warning: ISO C99 requires rest arguments to be used [enabled by default]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\chips\pn53x.c:2377:
71: warning: ISO C99 requires rest arguments to be used [enabled by default]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\chips\pn53x.c: In f
unction 'pn53x_check_error_frame':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\libnfc\chips\pn53x.c:2386:
77: warning: ISO C99 requires rest arguments to be used [enabled by default]
Linking C shared library libnfc.dll
Creating library file: libnfc.dll.a
[ 40%] Built target nfc
Scanning dependencies of target nfcutils
[ 44%] Building C object utils/CMakeFiles/nfcutils.dir/nfc-utils.c.obj
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-utils.c: In func
tion 'print_nfc_iso14443a_info':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-utils.c:273:13:
warning: unknown conversion type character 'z' in format [-Wformat]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-utils.c:273:13:
warning: too many arguments for format [-Wformat-extra-args]
Linking C static library libnfcutils.a
[ 44%] Built target nfcutils
Scanning dependencies of target nfc-emulate-forum-tag2
[ 48%] Building C object utils/CMakeFiles/nfc-emulate-forum-tag2.dir/nfc-emulate
-forum-tag2.c.obj
Linking C executable nfc-emulate-forum-tag2.exe
[ 48%] Built target nfc-emulate-forum-tag2
Scanning dependencies of target nfc-emulate-forum-tag4
[ 51%] Building C object utils/CMakeFiles/nfc-emulate-forum-tag4.dir/nfc-emulate
-forum-tag4.c.obj
Linking C executable nfc-emulate-forum-tag4.exe
[ 51%] Built target nfc-emulate-forum-tag4
Scanning dependencies of target nfc-list
[ 55%] Building C object utils/CMakeFiles/nfc-list.dir/nfc-list.c.obj
Linking C executable nfc-list.exe
[ 55%] Built target nfc-list
Scanning dependencies of target nfc-mfclassic
[ 59%] Building C object utils/CMakeFiles/nfc-mfclassic.dir/nfc-mfclassic.c.obj
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-mfclassic.c: In
function 'main':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-mfclassic.c:461:
11: warning: variable 'pbtUID' set but not used [-Wunused-but-set-variable]
[ 62%] Building C object utils/CMakeFiles/nfc-mfclassic.dir/mifare.c.obj
Linking C executable nfc-mfclassic.exe
[ 62%] Built target nfc-mfclassic
Scanning dependencies of target nfc-mfultralight
[ 66%] Building C object utils/CMakeFiles/nfc-mfultralight.dir/nfc-mfultralight.
c.obj
[ 70%] Building C object utils/CMakeFiles/nfc-mfultralight.dir/mifare.c.obj
Linking C executable nfc-mfultralight.exe
[ 70%] Built target nfc-mfultralight
Scanning dependencies of target nfc-relay-picc
[ 74%] Building C object utils/CMakeFiles/nfc-relay-picc.dir/nfc-relay-picc.c.ob
j
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-relay-picc.c: In
function 'print_hex_fd4':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-relay-picc.c:101
:3: warning: unknown conversion type character 'z' in format [-Wformat]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-relay-picc.c:101
:3: warning: too many arguments for format [-Wformat-extra-args]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-relay-picc.c: In
function 'main':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-relay-picc.c:213
:7: warning: unknown conversion type character 'z' in format [-Wformat]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-relay-picc.c:213
:7: warning: too many arguments for format [-Wformat-extra-args]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\utils\nfc-relay-picc.c:424
:9: warning: implicit declaration of function 'sleep' [-Wimplicit-function-decla
ration]
Linking C executable nfc-relay-picc.exe
[ 74%] Built target nfc-relay-picc
Scanning dependencies of target nfc-anticol
[ 77%] Building C object examples/CMakeFiles/nfc-anticol.dir/nfc-anticol.c.obj
Linking C executable nfc-anticol.exe
[ 77%] Built target nfc-anticol
Scanning dependencies of target nfc-dep-initiator
[ 81%] Building C object examples/CMakeFiles/nfc-dep-initiator.dir/nfc-dep-initi
ator.c.obj
Linking C executable nfc-dep-initiator.exe
[ 81%] Built target nfc-dep-initiator
Scanning dependencies of target nfc-dep-target
[ 85%] Building C object examples/CMakeFiles/nfc-dep-target.dir/nfc-dep-target.c
.obj
Linking C executable nfc-dep-target.exe
[ 85%] Built target nfc-dep-target
Scanning dependencies of target nfc-emulate-tag
[ 88%] Building C object examples/CMakeFiles/nfc-emulate-tag.dir/nfc-emulate-tag
.c.obj
Linking C executable nfc-emulate-tag.exe
[ 88%] Built target nfc-emulate-tag
Scanning dependencies of target nfc-emulate-uid
[ 92%] Building C object examples/CMakeFiles/nfc-emulate-uid.dir/nfc-emulate-uid
.c.obj
Linking C executable nfc-emulate-uid.exe
[ 92%] Built target nfc-emulate-uid
Scanning dependencies of target nfc-poll
[ 96%] Building C object examples/CMakeFiles/nfc-poll.dir/nfc-poll.c.obj
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\examples\nfc-poll.c: In fu
nction 'main':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\examples\nfc-poll.c:123:5:
warning: unknown conversion type character 'z' in format [-Wformat]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\examples\nfc-poll.c:123:5:
warning: too many arguments for format [-Wformat-extra-args]
Linking C executable nfc-poll.exe
[ 96%] Built target nfc-poll
Scanning dependencies of target nfc-relay
[100%] Building C object examples/CMakeFiles/nfc-relay.dir/nfc-relay.c.obj
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\examples\nfc-relay.c: In f
unction 'main':
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\examples\nfc-relay.c:121:5
: warning: unknown conversion type character 'z' in format [-Wformat]
C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\examples\nfc-relay.c:121:5
: warning: too many arguments for format [-Wformat-extra-args]
Linking C executable nfc-relay.exe
[100%] Built target nfc-relay

C:\Users\UCS3\Desktop\NFC\library\Source\libnfc-1.5.1\DLL>



I have a DLL that was created but how to use visual studio to make an API in C #?

but how to be sure that everything is created (many warning)?

When I connect my PN533 and I run an example, he said: unable to connect to device...

help.

Re: [SOLVED] Mingw problem with makefile libnfc 1.4.2

Hi GGelec,

GGelec wrote:

I have a DLL that was created but how to use visual studio to make an API in C #?

If you want to use it from C# you will need to use the .NET P/Invoke system to wrap the c library.

GGelec wrote:

but how to be sure that everything is created (many warning)?
When I connect my PN533 and I run an example, he said: unable to connect to device...

Your compilation log looks fine to me; there are some warning but no errors.
Please make sure you have activated the LIBNFC_DRIVER_PN53X_USB cmake build option.
You can check this by running

cmake-gui .

from the build directory.

Re: [SOLVED] Mingw problem with makefile libnfc 1.4.2

glenn wrote:

If you want to use it from C# you will need to use the .NET P/Invoke system to wrap the c library.

Thank you for your answer.

I looked on the Microsoft MSDN site.

http://msdn.microsoft.com/en-us/library/aa288468 (v = vs.71). aspx

I created a project in c #, I stuck my dll in the main directory. I do not really know where to put my dll now.

I'm having some issues regarding to declare a function of libnfc. I do not know what to put as a function declaration:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {

        [DllImport("libnfc.dll")]
        public static extern nfc_device_t* nfc_connect(nfc_device_desc_t* pndd);     <<<<<<<<<<<< HERE

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            nfc_connect(null);
        }
    }
}

public static extern is required.

But I can not see how the function must be declared with parameters.
I looked in the doc to see the function declaration in an include but it does not help me.

I saw in the doc that it is structure. How can you declare the function properly?

thank you

Re: [SOLVED] Mingw problem with makefile libnfc 1.4.2

nobody have an idea?

Re: [SOLVED] Mingw problem with makefile libnfc 1.4.2

[DllImport("libnfc.dll")]
        public static extern IntPtr nfc_connect(IntPtr pndd);

someone already used the libnfc with dllimport and Pinvoke?

Re: [SOLVED] Mingw problem with makefile libnfc 1.4.2

I can not connect to the NFC reader (PN533).

I know the steps to compile the library but I can not find a good explanation.

I'm not sure of the way I have to specify the file to include and libraries (libusb).

a few posts above, I put the path that I specified but no one told me that this is the place to put them.

By running the sample programs, he said he is not able to connect to my devices but he found it.

i forgot manipulation with lib USB? However I did create a PN533.inf well and I successfully installed.

Does anyone can confirm the path to the folder and include libusb libUSB_LIBRARIES?

thank you!

Re: [SOLVED] Mingw problem with makefile libnfc 1.4.2

okay, now it works.
I cleaned my machine and I redo all the steps.

Now my reader is recognized by the examples of libnfc and was able to establish some transfer.

But I'm still stuck with C #.

someone already used with libnfc DLLImport?

I would have just such a example of declaration type.

I found this at the moment but I can not test:

[DllImport ("libnfc.dll")]
         public static extern IntPtr nfc_connect (IntPtr PNDD);

thank you