frankmorgner / vsmartcard

umbrella project for emulation of smart card readers or smart cards
http://frankmorgner.github.io/vsmartcard/
712 stars 200 forks source link

Unable to configure PCSC - relay on mac #277

Closed siddhantmishra1305 closed 4 months ago

siddhantmishra1305 commented 4 months ago

I am trying to configure pcsc-relay on macOS but getting below error:

loading "libpcsclite_real.so.1" failed: dlopen(libpcsclite_real.so.1, 0x0001): tried: 'libpcsclite_real.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibpcsclite_real.so.1' (no such file), '/usr/lib/libpcsclite_real.so.1' (no such file, not in dyld cache), 'libpcsclite_real.so.1' (no such file) Could not connect to PC/SC Service Internal error. Compiled without support for libnfc AFAIK libpcsclite is only available for linux.

So is pcsc-relay even supported on mac ?

frankmorgner commented 4 months ago

it should be detected automatically. What's the output of ./configure?

siddhantmishra1305 commented 4 months ago

On running ./configure I got below error:



configure: error: winscard.h not found, install PC/SC Lite or similar or use ./configure PCSC_CFLAGS=...
 


I ran below command to set the variables and tried again.

export PKG_CONFIG_PATH="/opt/homebrew/opt/pcsc-lite/lib/pkgconfig”
export CPPFLAGS="-I/opt/homebrew/opt/pcsc-lite/include"  

export LDFLAGS="-L/opt/homebrew/opt/pcsc-lite/lib"



After setting above variables pcsc-relay got configured successfully.

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... mkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking for python... /usr/local/bin/python
checking for python version... 3.12
checking for python platform... darwin
checking for GNU default python prefix... ${prefix}
checking for GNU default python exec_prefix... ${exec_prefix}
checking for python script directory (pythondir)... ${PYTHON_PREFIX}/lib/python3.12/site-packages
checking for python extension module directory (pyexecdir)... ${PYTHON_EXEC_PREFIX}/lib/python3.12/site-packages
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking build system type... aarch64-apple-darwin23.4.0
checking host system type... aarch64-apple-darwin23.4.0
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... -D_THREAD_SAFE
checking for PTHREAD_PRIO_INHERIT... yes
checking for help2man... /opt/homebrew/bin/help2man
checking for gengetopt... /opt/homebrew/bin/gengetopt
checking whether make supports nested variables... (cached) yes
checking for libpcsclite... yes
checking for libnfc >= 1.6... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for vfork.h... no
checking for PCSC/winscard.h... yes
checking for reader.h... yes
checking for wintypes.h... yes
checking for pcsclite.h... yes
checking for SCardEstablishContext... yes
checking for nfc/nfc.h... yes
checking for nfc_initiator_select_passive_target... yes
checking for fcntl.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking for termios.h... yes
checking for size_t... yes
checking for ssize_t... yes
checking for uint8_t... yes
checking for gcc options needed to detect all undeclared functions... none needed
checking whether SO_NOSIGPIPE is declared... yes
checking whether MSG_NOSIGNAL is declared... yes
checking for sigaction... yes
checking for tcgetattr... yes
checking for strerror... yes
checking for strtol... yes
checking for strtoul... yes
checking for pid_t... yes
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for GNU libc compatible malloc... yes
checking for GNU libc compatible realloc... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands

pcsc-relay has been configured with following options:

Version:              0.6
User binaries:        /usr/local/bin
Enable libnfc:        yes

OpenPICC device:      /dev/ttyACM0

Host:                 aarch64-apple-darwin23.4.0
Compiler:             gcc
Preprocessor flags:   -I/opt/homebrew/opt/pcsc-lite/include
Compiler flags:       -g -O2
Linker flags:         -L/opt/homebrew/opt/pcsc-lite/lib
Libraries:            

PTHREAD_LIBS:         
PTHREAD_CFLAGS:       -D_THREAD_SAFE -pthread
PCSC_CFLAGS:          -I/opt/homebrew/Cellar/pcsc-lite/2.2.1/include/PCSC
PCSC_LIBS:            -L/opt/homebrew/Cellar/pcsc-lite/2.2.1/lib -lpcsclite
LIBNFC_CFLAGS:        -I/tmp/install/include -I/opt/homebrew/Cellar/libusb-compat/0.1.8/include -I/opt/homebrew/Cellar/libusb/HEAD-fef78a9/include/libusb-1.0
LIBNFC_LIBS:          -L/tmp/install/lib -L/opt/homebrew/Cellar/libusb-compat/0.1.8/lib -lnfc -lusb

HELP2MAN:             /opt/homebrew/bin/help2man
GENGETOPT:            /opt/homebrew/bin/gengetopt

But still If I try to run pcsc-relay I see below error:

loading "libpcsclite_real.so.1" failed: dlopen(libpcsclite_real.so.1, 0x0001): tried: 'libpcsclite_real.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibpcsclite_real.so.1' (no such file), '/usr/lib/libpcsclite_real.so.1' (no such file, not in dyld cache), 'libpcsclite_real.so.1' (no such file)
Could not connect to PC/SC Service
Internal error.
frankmorgner commented 4 months ago

you need to install XCode with its PC/SC headers/libs. PCSC-Lite (the homebrew project) is not tightly integrated into the OS, I think.

siddhantmishra1305 commented 4 months ago

Okay so I just built PCSC-lite repo alocally and then pcsc-relay started working fine.