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

loading "libpcsclite_real.so.1" failed: Dynamic loading not supported #216

Closed
areqq opened this issue Dec 22, 2024 · 12 comments
Closed

loading "libpcsclite_real.so.1" failed: Dynamic loading not supported #216

areqq opened this issue Dec 22, 2024 · 12 comments
Assignees
Labels

Comments

@areqq
Copy link

areqq commented Dec 22, 2024

Platform

  • Alpine Linux v3.21 x86_64
  • pcsc-lite-2.2.3 ccid-1.5.5

Issue

I'm trying to build the application statically. Build wuth PCSC_LIB=/usr/lib/libpcsclite.a, the resulting binary doesn't contain any dynamic references. However, when I run it I get an error:
loading "libpcsclite_real.so.1" failed: Dynamic loading not supported
I tried linking libpcsclite_real.a, but it doesn't help.

How can I build the application full statically without reference to libpcsclite_real.so.1 ?

I think the problem is with versions newer than 2.0.3.

@LudovicRousseau
Copy link
Owner

Interesting question.
libpcsclite is not designed to be used statically.

How have you generated /usr/lib/libpcsclite.a?

@areqq
Copy link
Author

areqq commented Dec 22, 2024

I use Alpine Linux - their package pcsc-lite-static provides /usr/lib/libpcsclite.a
build log:
https://build.alpinelinux.org/buildlogs/build-edge-x86/main/pcsc-lite/pcsc-lite-2.3.0-r0.log
https://pkgs.alpinelinux.org/package/edge/main/x86/pcsc-lite

Up until version 2.0.3 I was using libpcsclite statically linking without any problems. I would appreciate any help in finding a solution for current and future versions.

@LudovicRousseau
Copy link
Owner

The Alpine build log does not contain the line used to configure & build pcsc-lite :-(
It looks like the argument -D default_library=both is used.
In this case I see both libpcsclite.so.1 and libpcsclite.a are generated.

But since pcsc-lite 2.1.0 a new mechanism has been added. See https://blog.apdu.fr/posts/2024/04/how-to-use-libpcsclite_delegate/
I would have to remove support of LIBPCSCLITE_DELEGATE and make other changes to get a working static library.

Why do you want to statically link with libpcsclite?

@areqq
Copy link
Author

areqq commented Dec 23, 2024

Thank you for your interest. I want to get the smallest possible binary that will work on virtually any x86_64 linux distribution without any dependences, that's why I build it staticly on alpine linux which has small libc musl, thanks to which the resulting binary is small and universal.

@LudovicRousseau
Copy link
Owner

I pushed some patches ed790dc to allow the build of libpcsclite as a static library.

Alpine Linux will have to specifically configure pcsc-lite with -Ddefault_library=static to generate the static version. It is not possible to generate both static and shared versions at the same time.
Someone will have to modify https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/pcsc-lite/APKBUILD to add this support.

@areqq
Copy link
Author

areqq commented Dec 23, 2024

Thanks! Are you planning to release a new version soon? If yes, I’ll reach out to the Alpine package maintainer to request an update.

@LudovicRousseau
Copy link
Owner

Yes, "soon".

LudovicRousseau added a commit to LudovicRousseau/PCSC-devel that referenced this issue Dec 24, 2024
We now build both versions of the library: dynamic and static.

In the case of static library it is no more possible to use
LIBPCSCLITE_DELEGATE to redirect to another libpcsclite.

Thanks to areqq for the bug report
" loading "libpcsclite_real.so.1" failed: Dynamic loading not supported #216 "
LudovicRousseau/PCSC#216 (comment)
@LudovicRousseau
Copy link
Owner

New release available: https://blog.apdu.fr/posts/2024/12/new-version-of-pcsc-lite-231/

I changed my patch . The static library is now built by default. No need to use a special configuration argument.
It should be easy for the Alpine maintainer.

@LudovicRousseau
Copy link
Owner

@areqq
Copy link
Author

areqq commented Dec 24, 2024

Thanks a lot for your quick response and solving my problem—really impressed!

By the way, I have a another question about static builds: is there a way to build a static pcscd + ccid that doesn’t require libccid.so?

@LudovicRousseau
Copy link
Owner

Please open a new issue for that.

@LudovicRousseau
Copy link
Owner

See #217 for the static pcscd + ccid issue.

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

No branches or pull requests

2 participants