Sample Header Ad - 728x90

pkg-config cannot find any libraries without manual intervention

0 votes
1 answer
1383 views
I am not a C++ developer or typically work with Conan, CMake, or Makefiles. The first time I had heard of pkg-config was yesterday when conan started erroring on it, unable to resolve a gl package. I managed to get it working with export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig". Today, I tried to build spotify_player with cargo and it failed, unable to find the alsa library:
--- stderr
  thread 'main' panicked at 'PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "alsa" did not exit successfully: exit status: 1
  error: could not find system library 'alsa' required by the 'alsa-sys' crate

  --- stderr
  Package alsa was not found in the pkg-config search path.
  Perhaps you should add the directory containing `alsa.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'alsa' found
  ', /home/xevion/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alsa-sys-0.3.1/build.rs:13:18
  note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
I looked around and found alsa.pc at /usr/lib/x86_64-linux-gnu/pkgconfig/alsa.pc. Exporting the variable in the exact same fashion as above fixes it. That said, while it works - something is wrong. I was able to build and install spotify_sound in the exact same way as before a couple months ago. Nothing should have changed. - I've reinstalled all associated libraries with alsa, as well as pkg-config. - I'm working in a new terminal session. - I've confirmed that pkg-config isn't finding it with pkg-config --debug alsa. - Running Pop!_OS 22.04 LTS (Ubuntu 22.04) on a Lenovo ThinkPad X1 Carbon Gen 6. .pc files can be found all over my computer - exporting in my .bashrc seems like a blockhead solution - something is happening on a greater level. How do I fix pkg-config on my machine?
Asked by Xevion (103 rep)
Sep 26, 2023, 07:48 PM
Last activity: Oct 27, 2023, 03:59 PM