Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to `pcsc_assert_wire_constants' error when cross compiling with newest 2.2.0 version #184

Closed
gabberhead opened this issue May 8, 2024 · 5 comments

Comments

@gabberhead
Copy link

gabberhead commented May 8, 2024

with the older 2.1.0 version i could succesful cross compile on a x64 machine with debian for mipsel with this:

wget https://pcsclite.apdu.fr/files/pcsc-lite-2.1.0.tar.bz2
tar -xf pcsc-lite-2.1.0.tar.bz2 && cd pcsc-lite-2.1.0
export TOOLCHAIN=/opt/broadcom_7.0
export PATH="$TOOLCHAIN/bin:$PATH"
./configure --prefix=$TOOLCHAIN/mipsel-unknown-linux-gnu/sys-root/usr/ --host=mipsel-unknown-linux-gnu --disable-polkit --disable-libsystemd --disable-libudev --disable-documentation --enable-libusb LIBUSB_LIBS="-L$TOOLCHAIN/mipsel-unknown-linux-gnu/sys-root/usr/lib -lusb-1.0" LIBUSB_CFLAGS="-I$TOOLCHAIN/mipsel-unknown-linux-gnu/sys-root/usr/include/libusb-1.0"
make
make install

but this is not working anymore with the newest 2.2.0 version on the same machine. now i can configure it like this:

wget https://pcsclite.apdu.fr/files/pcsc-lite-2.2.0.tar.xz
tar -xf pcsc-lite-2.2.0.tar.xz && cd pcsc-lite-2.2.0
export TOOLCHAIN=/opt/broadcom_7.0
export PATH="$TOOLCHAIN/bin:$PATH"
./bootstrap &&
./configure
--prefix=$TOOLCHAIN/mipsel-unknown-linux-gnu/sys-root/usr/
--host=mipsel-unknown-linux-gnu
--disable-polkit
--disable-libsystemd
--disable-libudev
--disable-documentation
--enable-libusb LIBUSB_LIBS="-L$TOOLCHAIN/mipsel-unknown-linux-gnu/sys-root/usr/lib -lusb-1.0" LIBUSB_CFLAGS="-I$TOOLCHAIN/mipsel-unknown-linux-gnu/sys-root/usr/include/libusb-1.0"

and this works. but when i now do make, i get the following error:

/tmp/pcsc-lite-2.2.0# make
make all-recursive
make[1]: Verzeichnis „/tmp/pcsc-lite-2.2.0“ wird betreten
Making all in src
make[2]: Verzeichnis „/tmp/pcsc-lite-2.2.0/src“ wird betreten
Making all in spy
make[3]: Verzeichnis „/tmp/pcsc-lite-2.2.0/src/spy“ wird betreten
CC libpcscspy.lo
CC ../sys_unix.lo
CCLD libpcscspy.la
make[3]: Verzeichnis „/tmp/pcsc-lite-2.2.0/src/spy“ wird verlassen
make[3]: Verzeichnis „/tmp/pcsc-lite-2.2.0/src“ wird betreten
CC testpcsc.o
CC error.lo
CC libredirect.lo
CCLD libpcsclite.la
CCLD testpcsc
CC pcsc-wirecheck-gen.o
CCLD pcsc-wirecheck-gen
rm -f pcsc-wirecheck-dist.c
./pcsc-wirecheck-gen > pcsc-wirecheck-dist.c.tmp
/bin/bash: Zeile 8: ./pcsc-wirecheck-gen: Kann die Binärdatei nicht ausführen: Fehler im Format der Programmdatei
mv pcsc-wirecheck-dist.c.tmp pcsc-wirecheck-dist.c
CC pcsc-wirecheck-dist.o
CC pcsc-wirecheck-main.o
CCLD pcsc-wirecheck
/opt/broadcom/bin/../lib/gcc/mipsel-unknown-linux-gnu/8.3.0/../../../../mipsel-unknown-linux-gnu/bin/ld: pcsc-wirecheck-main.o: in function main': /tmp/pcsc-lite-2.2.0/src/pcsc-wirecheck-main.c:12: undefined reference to pcsc_assert_wire_constants'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:783: pcsc-wirecheck] Fehler 1
make[3]: Verzeichnis „/tmp/pcsc-lite-2.2.0/src“ wird verlassen
make[2]: *** [Makefile:1332: all-recursive] Fehler 1
make[2]: Verzeichnis „/tmp/pcsc-lite-2.2.0/src“ wird verlassen
make[1]: *** [Makefile:444: all-recursive] Fehler 1
make[1]: Verzeichnis „/tmp/pcsc-lite-2.2.0“ wird verlassen
make: *** [Makefile:374: all] Fehler 2

i dont know, how to get it to work. thats why i am asking here for help :) or is this a bug? thanx for your answer in advance ;)

@LudovicRousseau
Copy link
Owner

You should use meson instead of configure/make.

See https://blog.apdu.fr/posts/2024/05/pcsc-lite-now-uses-meson-build-tool/

@gabberhead
Copy link
Author

never used mason. i tried now :) but i have a problem with libusb. i get the following error:

/tmp# meson setup pcsc-lite-2.2.0 --cross-file mipsel -Dpolkit=false -Dlibsystemd=false -Dlibudev=false -Dlibusb=true
WARNING: Unknown CPU family mipsel, please report this at https://github.com/mesonbuild/meson/issues/new
The Meson build system
Version: 0.56.2
Source dir: /tmp/pcsc-lite-2.2.0
Build dir: /tmp
Build type: cross build
Project name: pcsc-lite
Project version: 2.2.0
C compiler for the host machine: mipsel-unknown-linux-gnu-gcc (gcc 8.3.0 "mipsel-unknown-linux-gnu-gcc (stbgcc-8.3-1.0) 8.3.0")
C linker for the host machine: mipsel-unknown-linux-gnu-gcc ld.bfd 8.3-1
C compiler for the build machine: cc (gcc 10.2.1 "cc (Debian 10.2.1-6) 10.2.1 20210110")
C linker for the build machine: cc ld.bfd 2.35.2
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86_64
Host machine cpu: x86_64
Target machine cpu family: mipsel
Target machine cpu: mipsel
Checking for function "getrandom" : YES
Checking for function "secure_getenv" : YES
Checking for function "getopt_long" : YES
Program flex found: YES (/usr/bin/flex)
Run-time dependency threads found: YES
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Found CMake: NO
**Run-time dependency libusb-1.0 found: NO (tried pkgconfig)

pcsc-lite-2.2.0/meson.build:102:2: ERROR: Dependency "libusb-1.0" not found, tried pkgconfig

A full log can be found at /tmp/meson-logs/meson-log.txt**

the cross file looks like this:

[binaries]
c = 'mipsel-unknown-linux-gnu-gcc'
cpp = 'mipsel-unknown-linux-gnu-g++'
ar = 'mipsel-unknown-linux-gnu-gcc-ar'
strip = 'mipsel-unknown-linux-gnu-strip'
pkgconfig = 'pkg-config'

[host_machine]
system = 'linux'
cpu_family = 'mipsel'
cpu = 'mipsel'
endian = 'little'

i think this is missing for meson, the old way i used:

LIBUSB_LIBS="-L$TOOLCHAIN/mipsel-unknown-linux-gnu/sys-root/usr/lib -lusb-1.0" LIBUSB_CFLAGS="-I$TOOLCHAIN/mipsel-unknown-linux-gnu/sys-root/usr/include/libusb-1.0"

but i dont know how to use this with meson.

@LudovicRousseau
Copy link
Owner

I never used cross compilation.

https://blog.apdu.fr/posts/2020/11/how-to-get-smart-card-support/

@gabberhead
Copy link
Author

for years, there was no problem. is there no way to get it worked like it was before? or it is the old method now deprecated?

@gabberhead
Copy link
Author

i managed to get it worked. the problem was in the file: pcsc-wirecheck-main.c

the default values in this file are:

#include <stdio.h>

int pcsc_assert_wire_constants(void);

int
main (/@unused@/ int argc, /@unused@/ char **argv)
{
(void)argc;
(void)argv;

printf("Checking ABI...\n");
if (0 == pcsc_assert_wire_constants ())
	printf("OK\n");
return 0;

}

with this it dont work. but when i change the line:

if (0 == pcsc_assert_wire_constants ())

to

if (0 == 0)

then it works without problem. i dont know if pcsc_assert_wire_constants is important, but without it, now it works like before.

the complete way i cross compile it looks like this now:

wget https://pcsclite.apdu.fr/files/pcsc-lite-2.2.1.tar.xz
tar -xf pcsc-lite-2.2.1.tar.xz && cd pcsc-lite-2.2.1
export TOOLCHAIN=/opt/broadcom
export PATH="$TOOLCHAIN/bin:$PATH"
find . -name "pcsc-wirecheck-main.c" -type f -exec sed -i 's/pcsc_assert_wire_constants ()/0/g' {} ;;
./bootstrap &&
./configure
--prefix=$TOOLCHAIN/mipsel-unknown-linux-gnu/sys-root/usr/
--host=mipsel-unknown-linux-gnu
--disable-polkit
--disable-libsystemd
--disable-libudev
--disable-documentation
--enable-libusb LIBUSB_LIBS="-L$TOOLCHAIN/mipsel-unknown-linux-gnu/sys-root/usr/lib -lusb-1.0" LIBUSB_CFLAGS="-I$TOOLCHAIN/mipsel-unknown-linux-gnu/sys-root/usr/include/libusb-1.0"
make
make install
cd ..
rm -fr pcsc-lite-2.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants