timmerk / nfc-tools

Automatically exported from code.google.com/p/nfc-tools
0 stars 0 forks source link

Endianness problems when compiling on Mac OS X 10.7.2 #83

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. inside libfreefare-0.3.2 dir, run ./configure --prefix=/usr
2. make

What is the expected output? What do you see instead?
The expected output should not have the warnings that I see:

Smooth-Lightning:libfreefare-0.3.2 kevin$ make
make  all-recursive
Making all in contrib
Making all in libutil
make[3]: Nothing to be done for `all'.
make[3]: Nothing to be done for `all-am'.
Making all in libfreefare
  CC     freefare.lo
  CC     mifare_classic.lo
mifare_classic.c: In function ‘mifare_classic_init_value’:
mifare_classic.c:326: warning: implicit declaration of function ‘htole32’
mifare_classic.c: In function ‘mifare_classic_read_value’:
mifare_classic.c:364: warning: implicit declaration of function ‘le32toh’
  CC     mifare_ultralight.lo
mifare_ultralight.c: In function ‘mifare_ultralightc_authenticate’:
mifare_ultralight.c:265: warning: ‘DES_random_key’ is deprecated (declared 
at /usr/include/openssl/des.h:218)
  CC     mifare_desfire.lo
mifare_desfire.c: In function ‘authenticate’:
mifare_desfire.c:355: warning: ‘RAND_bytes’ is deprecated (declared at 
/usr/include/openssl/rand.h:104)
mifare_desfire.c: In function ‘mifare_desfire_get_df_names’:
mifare_desfire.c:826: warning: implicit declaration of function ‘le16toh’
mifare_desfire.c: In function ‘mifare_desfire_get_file_settings’:
mifare_desfire.c:1249: warning: implicit declaration of function ‘le32toh’
  CC     mifare_desfire_aid.lo
...

Basically, some of the endian macros defined in freefare_internal.h are not 
working. The compilation succeeds, but when trying to run some of the examples 
(like mifare-classic-write-ndef), I get the following:

dyld: lazy symbol binding failed: Symbol not found: _htole32
  Referenced from: /Users/kevin/dev/libfreefare-0.3.2/libfreefare/.libs/libfreefare.0.dylib
  Expected in: flat namespace

dyld: Symbol not found: _htole32
  Referenced from: /Users/kevin/dev/libfreefare-0.3.2/libfreefare/.libs/libfreefare.0.dylib
  Expected in: flat namespace

Which makes sense, since during compilation, those were never defined.

What version of the product are you using? On what operating system?
OS: Mac OS X 10.7.
Version: libfreefare-0.3.2

Please provide any additional information below.

Original issue reported on code.google.com by kev.y.w...@gmail.com on 2 Jan 2012 at 3:54

GoogleCodeExporter commented 9 years ago
Looking at it some more, would #ifdef macros in freefare_internal.h that use 
<libkern/OSByteOrder.h> work?

Original comment by kev.y.w...@gmail.com on 2 Jan 2012 at 11:08

GoogleCodeExporter commented 9 years ago
Maybe the solution is to use _standard_ C functions like:

NAME
     htonl, htons, ntohl, ntohs -- convert values between host and network
     byte order

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <arpa/inet.h>

     uint32_t
     htonl(uint32_t hostlong);

     uint16_t
     htons(uint16_t hostshort);

     uint32_t
     ntohl(uint32_t netlong);

     uint16_t
     ntohs(uint16_t netshort);

Original comment by ludovic....@gmail.com on 19 May 2012 at 11:19

GoogleCodeExporter commented 9 years ago

Original comment by romu...@libnfc.org on 1 Jun 2012 at 12:02

GoogleCodeExporter commented 9 years ago
Moved to https://code.google.com/p/libfreefare/issues/detail?id=2

Original comment by yob...@gmail.com on 15 Jan 2013 at 7:47