xantares / nfc-bindings

scripting language bindings for libnfc
BSD 3-Clause "New" or "Revised" License
23 stars 9 forks source link

make: *** No rule to make target 'install'. Stop. #9

Closed gabicavalcante closed 6 years ago

gabicavalcante commented 6 years ago

When I run the Quickstart:

pi@raspberrypi:~ $ git clone https://github.com/xantares/nfc-bindings.git
Cloning into 'nfc-bindings'...
remote: Counting objects: 350, done.
remote: Total 350 (delta 0), reused 0 (delta 0), pack-reused 350
Receiving objects: 100% (350/350), 54.62 KiB | 0 bytes/s, done.
Resolving deltas: 100% (201/201), done.
Checking connectivity... done.
pi@raspberrypi:~ $ cd nfc-bindings
pi@raspberrypi:~/nfc-bindings $ cmake -DCMAKE_INSTALL_PREFIX=~/.local .
-- The C compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.28")
-- Checking for module 'libnfc'
--   Found libnfc, version 1.7.1
-- Found LibNFC: /usr/local/lib/libnfc.so (found suitable version "1.7.1", minimum required is "1.7.1")
-- Looking for iso14443b_crc
-- Looking for iso14443b_crc - found
-- Could NOT find SWIG (missing:  SWIG_EXECUTABLE SWIG_DIR)
-- Found PythonLibs: /usr/lib/arm-linux-gnueabihf/libpython3.4m.so (found version "3.4.2")
-- Found PythonInterp: /usr/bin/python3.4 (found version "3.4.2")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/nfc-bindings
pi@raspberrypi:~/nfc-bindings $ make install
make: *** No rule to make target 'install'.  Stop.
xantares commented 6 years ago

you're missing swig, I made it mandatory now

gabicavalcante commented 6 years ago

Thanks! I got a error, and I thought it would be resolved after making make install. But I got the same error now:

pi@raspberrypi:~/nfc-bindings $ python python/examples/quick_start_example.py
Version:  0.13.2
Traceback (most recent call last):
  File "python/examples/quick_start_example.py", line 11, in <module>
    context = nfc.init()
AttributeError: 'module' object has no attribute 'init'

Do you know why this is happening?

xantares commented 6 years ago

I suspect the nfc module that you're trying to load is not the one you thought you installed as the version reported 0.13.2 should be the same as the libnfc version. Did you make install ? Did you set the install prefix ? Also 'python' should point to python of version 3.4, maybe you should run it with 'python3'.

gabicavalcante commented 6 years ago

I tried with python 3.

pi@raspberrypi:~/nfc-bindings $ python3 python/examples/quick_start_example.py
Version:  libnfc-1.7.1-191-g216145f
ERROR: Unable to open NFC device.

When I test the libnfc, I don't have any problem:

pi@raspberrypi:~/libnfc/examples $ sudo ./nfc-poll
/home/pi/libnfc/examples/.libs/lt-nfc-poll uses libnfc libnfc-1.7.1-191-g216145f
NFC reader: PN532 board via UART opened
NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations)
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04
       UID (NFCID1): 04  5b  8f  0e
      SAK (SEL_RES): 08
Waiting for card removing...

My scheme: https://github.com/emersonmello/doorlock_raspberrypi/blob/master/hw-wiring.png

xantares commented 6 years ago

maybe the sudo grants you rigts to your device here ?

gabicavalcante commented 6 years ago

I tried without sudo, and the libnfc works:

pi@raspberrypi:~/libnfc/examples $ ./nfc-poll
/home/pi/libnfc/examples/.libs/lt-nfc-poll uses libnfc libnfc-1.7.1-191-g216145f
NFC reader: PN532 board via UART opened
NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations)
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04
       UID (NFCID1): 04  5b  8f  0e
      SAK (SEL_RES): 08
Waiting for card removing...

I tried with sudo now:

pi@raspberrypi:~/nfc-bindings $ sudo python3 python/examples/quick_start_example.py
Traceback (most recent call last):
  File "python/examples/quick_start_example.py", line 8, in <module>
    import nfc
ImportError: No module named 'nfc'
xantares commented 6 years ago

did you use the same libnfc version ?

xantares commented 6 years ago

could you try with sudo but setting sudo PYTHONPATH=/home/pi/.local/lib/python3.4/site-packages python3 python/examples/quick_start_example.py ?

gabicavalcante commented 6 years ago

The version of libnfc is the same

libnfc:

pi@raspberrypi:~/libnfc/examples $ ./nfc-poll
/home/pi/libnfc/examples/.libs/lt-nfc-poll uses libnfc libnfc-1.7.1-191-g216145f

nfc-bindings:

pi@raspberrypi:~/nfc-bindings $ sudo PYTHONPATH=/home/pi/.local/lib/python3.4/site-packages python3 python/examples/quick_start_example.py
Version:  libnfc-1.7.1-191-g216145f
ERROR: Unable to open NFC device.

But tried the command nfc-list and I got an error:

nfc-list uses libnfc libnfc-1.7.1-191-g216145f
No NFC device found.

I'm gonna try to find a way to fix it.

gabicavalcante commented 6 years ago

I fixed the problem with libnfc, now:

pi@raspberrypi:~/nfc-bindings/python/examples $ nfc-list
nfc-list uses libnfc 1.7.1
NFC device: pn532_i2c:/dev/i2c-1 opened
1 ISO14443A passive target(s) found:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04  
       UID (NFCID1): e1  2f  ce  e9  
      SAK (SEL_RES): 08  

and

pi@raspberrypi:~/nfc-bindings $ swig -version

SWIG Version 2.0.12

Compiled with g++ [armv7l-unknown-linux-gnueabihf]

Configured options: +pcre

pi@raspberrypi:~/nfc-bindings $ python --version
Python 2.7.9

pi@raspberrypi:~/nfc-bindings $ nfc-list
nfc-list uses libnfc 1.7.1
NFC device: pn532_i2c:/dev/i2c-1 opened

pi@raspberrypi:~/nfc-bindings $ make --version
GNU Make 4.0

But when I try:

pi@raspberrypi:~/nfc-bindings/python/examples $ python quick_start_example.py 
Traceback (most recent call last):
  File "quick_start_example.py", line 8, in <module>
    import nfc
  File "/home/pi/.local/lib/python2.7/site-packages/nfc.py", line 32, in <module>
    _nfc = swig_import_helper()
  File "/home/pi/.local/lib/python2.7/site-packages/nfc.py", line 28, in swig_import_helper
    _mod = imp.load_module('_nfc', fp, pathname, description)
ImportError: /home/pi/.local/lib/python2.7/site-packages/_nfc.so: undefined symbol: iso14443b_crc

or

pi@raspberrypi:~/nfc-bindings/python/examples $ python3 quick_start_example.py 
Traceback (most recent call last):
  File "quick_start_example.py", line 8, in <module>
    import nfc
ImportError: No module named 'nfc'
xantares commented 6 years ago
gabicavalcante commented 6 years ago

I removed HAS_ISO14443B_CRC:INTERNAL=1 from CMakeCache.txt, but when I rerun cmake -DCMAKE_INSTALL_PREFIX=~/.local ., HAS_ISO14443B_CRC:INTERNAL=1 is in the file again. I'm doing the right command line?

gabicavalcante commented 6 years ago

I did:

pi@raspberrypi:~/nfc-bindings $ objdump -tT /usr/lib/libnfc.so|grep iso1444
00000000 l    df *ABS*  00000000              iso14443-subr.c
00011ea4 l     O .rodata    00000010              pn532_iso14443a_supported_baud_rates
00006504 l     F .text  000000bc              snprint_nfc_iso14443b2ct_info
00011e90 l     O .rodata    00000014              pn533_iso14443a_supported_baud_rates
00011e5c l     O .rodata    00000008              pn532_iso14443b_supported_baud_rates
00005f84 l     F .text  000003f0              snprint_nfc_iso14443b_info
000064c8 l     F .text  0000003c              snprint_nfc_iso14443b2sr_info
00011e48 l     O .rodata    00000014              pn533_iso14443b_supported_baud_rates
00004b1c l     F .text  000011cc              snprint_nfc_iso14443a_info
00002c30 l     F .text  000000b4              iso14443_cascade_uid
00006374 l     F .text  00000154              snprint_nfc_iso14443bi_info
00002b8c g     F .text  0000004c              iso14443b_crc
00002b84 g     F .text  00000008              iso14443a_crc_append
00002bd8 g     F .text  00000008              iso14443b_crc_append
00002be0 g     F .text  00000050              iso14443a_locate_historical_bytes
00002b3c g     F .text  00000048              iso14443a_crc
00002be0 g    DF .text  00000050  Base        iso14443a_locate_historical_bytes
00002b8c g    DF .text  0000004c  Base        iso14443b_crc
00002bd8 g    DF .text  00000008  Base        iso14443b_crc_append
00002b84 g    DF .text  00000008  Base        iso14443a_crc_append
00002b3c g    DF .text  00000048  Base        iso14443a_crc

So, there is iso14443b_crc...

xantares commented 6 years ago

Yes iso14443b_crc is exported, at least the one in /usr/lib/.

Which one is the bindings linked to ? ldd /home/pi/.local/lib/python2.7/site-packages/_nfc.so