Undefined reference when linking simple libmpv example

Hello,

I’m trying to use the mpv from the unstable channel (because it has a patch related to this issue),

but I can’t compile this example and gives me this error:

└─> gcc -o simple simple.c `pkg-config --libs --cflags mpv`

/nix/store/lz1bwpdvlywij5ir0fmncgqa83dlpwhn-binutils-2.39/bin/ld: /nix/store/qr4br1dgaiwxjr75xk8hh6p1avi5xyq8-openal-soft-1.22.2/lib/libopenal.so.1: undefined reference to `std::condition_variable::wait(std::unique_lock<std::mutex>&)@GLIBCXX_3.4.30'
collect2: error: ld returned 1 exit status

when I add mpv from the unstable channel in my shell.nix file:

let
  system = "x64_86-linux";
  unstable = import <nixos-unstable> { allowUnfree = true; };
in
{ pkgs ? import <nixpkgs> { allowUnfree = true; } }:
   pkgs.mkShell rec {
    buildInputs = with pkgs; [
      unstable.mpv
      pkg-config
    ];
  }

I also tried using mpv-unwrapped.dev, but didn’t work.

you can ask me for more context if needed :slight_smile:

Turns out that I was mixing 2 different channels (unstable, and 22.11 channel) which caused libmpv (or one of its dependencies) to be compiled with a different libstdc++ version than the one used when compiling the libmpv example

thanks to @TommyLuco for guiding me :slight_smile:

1 Like