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

Static Linking Through pkgconfig with LDAP/LBER is Broken #1619

Closed
dMaggot opened this issue Jun 27, 2017 · 0 comments
Closed

Static Linking Through pkgconfig with LDAP/LBER is Broken #1619

dMaggot opened this issue Jun 27, 2017 · 0 comments

Comments

@dMaggot
Copy link

dMaggot commented Jun 27, 2017

In Gentoo, the libcurl.pc file generated for pkg-config has the following line:

$ grep Libs.private /usr/lib64/pkgconfig/libcurl.pc
Libs.private: -llber -lldap

so a call to pkgconfig for static linking returns those libraries in that order:

$ pkg-config --static --libs libcurl
-lcurl -llber -lldap -lz -lssl -ldl -lz -lcrypto -ldl -lz

but ldap depends on lber so linking fails:

$ gcc -o test test.c -static pkg-config --libs --static libcurl
[lots of warnings]
result.c:(.text+0xa19): undefined reference to ber_get_int' result.c:(.text+0xa80): undefined reference to ber_scanf'
result.c:(.text+0xa98): undefined reference to ber_peek_tag' result.c:(.text+0xbcd): undefined reference to ber_scanf'
result.c:(.text+0xc58): undefined reference to ber_peek_tag' result.c:(.text+0xd86): undefined reference to ber_peek_tag'
result.c:(.text+0xe09): undefined reference to ber_scanf' result.c:(.text+0xe19): undefined reference to ber_peek_tag'
result.c:(.text+0x10c6): undefined reference to ber_scanf' result.c:(.text+0x1579): undefined reference to ber_scanf'
result.c:(.text+0x15e1): undefined reference to ber_peek_tag' result.c:(.text+0x1625): undefined reference to ber_peek_tag'
result.c:(.text+0x18a4): undefined reference to ber_scanf' result.c:(.text+0x1b13): undefined reference to ber_peek_tag'
result.c:(.text+0x1b94): undefined reference to ber_peek_tag' result.c:(.text+0x1cc5): undefined reference to ber_printf'
result.c:(.text+0x1ce9): undefined reference to ber_skip_tag' result.c:(.text+0x1cff): undefined reference to ber_get_enum'
result.c:(.text+0x1d15): undefined reference to `ber_peek_tag'

Compilation works if I manually swap the positions of lber and ldap in the command line.

bagder added a commit that referenced this issue Jul 3, 2017
When scanning for which LDAP libraries to use, try the -lldap -llber
combination before the reversed order since it has a greater chance of
working when linking with libcurl statically.

Fixes #1619
Reported-by: David E. Narváez
@bagder bagder closed this as completed in c534384 Jul 4, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants