Skip to content

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

@dMaggot

Description

@dMaggot

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions