Skip to content

Cannot use pkg-config to build a binary with libs #2004

@gnosek

Description

@gnosek

Describe the bug

Building a binary linked with libsinsp using pkg-config fails with multiple layers of errors. As of now, our pkg-config looks unusable.

How to reproduce it

  1. In the build directory:
rm -rf /tmp/libs ; make DESTDIR=/tmp/libs install
  1. Anywhere else, create test.cpp with the following content:
#include <libsinsp/sinsp.h>

int main()
{
    sinsp inspector;
}
  1. Try to build test.cpp
g++ test.cpp -o test $(PKG_CONFIG_PATH=/tmp/libs/usr/local/lib/pkgconfig pkg-config --static --cflags --libs libsinsp libscap)

Expected behaviour

I expected the binary to compile and link.

Screenshots

g++ test.cpp -o test $(PKG_CONFIG_PATH=/tmp/libs/usr/local/lib/pkgconfig pkg-config --static --cflags --libs libsinsp libscap)      [1]
/usr/bin/ld: cannot find -linstall_lib_link_libraries-NOTFOUND: No such file or directory
/usr/bin/ld: cannot find -lpman: No such file or directory
collect2: error: ld returned 1 exit status

I removed the bogus -linstall_lib_link_libraries-NOTFOUND and copied libpman.a over manually, so the linker at least tried to do the job. That resulted in thousands upon thousands lines of missing symbol errors, complaining about literally everything. I'm not going to paste everything here, so just a sample which seems to be about libbpf:

/usr/bin/ld: /tmp/libs/usr/local/lib/pkgconfig/../../lib/libpman.a(programs.c.o): in function `pman_detach_syscall_enter_dispatcher':
/home/blackfire/src/draios/workspace-oss/falco-libs/userspace/libpman/src/programs.c:196: undefined reference to `bpf_link__destroy'
/usr/bin/ld: /tmp/libs/usr/local/lib/pkgconfig/../../lib/libpman.a(programs.c.o): in function `pman_detach_syscall_exit_dispatcher':
/home/blackfire/src/draios/workspace-oss/falco-libs/userspace/libpman/src/programs.c:207: undefined reference to `bpf_link__destroy'
/usr/bin/ld: /tmp/libs/usr/local/lib/pkgconfig/../../lib/libpman.a(programs.c.o): in function `pman_detach_sched_proc_exit':
/home/blackfire/src/draios/workspace-oss/falco-libs/userspace/libpman/src/programs.c:218: undefined reference to `bpf_link__destroy'
/usr/bin/ld: /tmp/libs/usr/local/lib/pkgconfig/../../lib/libpman.a(programs.c.o): in function `pman_detach_sched_switch':
/home/blackfire/src/draios/workspace-oss/falco-libs/userspace/libpman/src/programs.c:229: undefined reference to `bpf_link__destroy'
/usr/bin/ld: /tmp/libs/usr/local/lib/pkgconfig/../../lib/libpman.a(programs.c.o): in function `pman_detach_page_fault_user':
/home/blackfire/src/draios/workspace-oss/falco-libs/userspace/libpman/src/programs.c:267: undefined reference to `bpf_link__destroy'
/usr/bin/ld: /tmp/libs/usr/local/lib/pkgconfig/../../lib/libpman.a(programs.c.o):/home/blackfire/src/draios/workspace-oss/falco-libs/userspace/libpman/src/programs.c:280: more undefined references to `bpf_link__destroy' follow
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status

Environment

  • Falco version: no Falco, some recent libs checkout
  • OS: pop_OS 22.04
  • Installation method: straight from source

Additional context

I can accept PEBKAC as an explanation (I'm several yaks deep and wanted this to Just Work) but I'd still like to have a binary in the end :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions