Change:
Hi, I created a minimal demonstrator for my problem: (not main branch but , to also build with nixos 22.11) This minimal C++ app includes and links against opencv4. Building this flake using works just fine and the resulting app works. Running and then doing results in link errors: With nixpkgs on 22.11, both nix build and nix develop work. Steps to reproduce the behavior: out reproducer repo , works nix shell using and run: , get mentioned error messages flake input to nixpkgs 22.11 step 1 & 2 and see that they work I would expect to not get these linker errors after upgrading to nixpkgs master If applicable, add screenshots to help explain your problem. Add any other context about the problem here. <!-- Please @ people who are in the list of the offending package or module. If in doubt, check for whoever last touched something. -- Please run and paste the result.
Hi :wave: Could you try building your flake with nixpkgs from the staging branch ? There are some changes that I've made to this package which are not yet merged into master , maybe it'll help. Also, I'm not very knowledgeable how c++ linking/compiling works, but from the look of this error messages it seems that dependencies of opencv - such as openmp, gstreamer, opencl, etc are missing from the environment. What if you add them explicitly, probably through opencv4.buildInputs ? P. S. Maintainers listed for this package seems to be not active anymore (they've never responded me from the last october till today)
I just finished bisecting nixpkgs: The commit breaks it for me. do you have any insights on that? I am trying staging now following your suggestion and will report back.
With dynamic linking, this should never be necessary. If it works with explicit linking against these deps, I would still consider this a bug.
Yeah, my apologies for the breakage. That change was reverted for a very similar reason in and is in now. Can you try that one instead? That hopefully should not be too many rebuilds on you.
Oh yes, thank you for pointing me to that, I try that branch.
It's already all in the binary cache, so that was quick. This resolved my problem, thank you!

Discussion:
# compile, because it uses "#include_next <limits.h>" to find the # limits.h file in ../includes-fixed. To remedy the problem, # another -idirafter is necessary to add that directory again. <del> # # We use --sysroot=/nix/store/does/not/exist to drop embedded default # path to glibc headers gcc was built against. Without it -idirafter # only appends to the list and outdated glibc headers end up being # used. 'cc-cflags-before' is used to allow user's --sysroot= option # to override our default. </del> + optionalString (libc != null) ('' touch "$out/nix-support/libc-cflags" touch "$out/nix-support/libc-ldflags" echo "-B${libc_lib}${libc.libdir or "/lib/"}" >> $out/nix-support/libc-crt1-cflags '' + optionalString (!(cc.langD or false)) '' <del> echo "--sysroot=/nix/store/does/not/exist" >> $out/nix-support/cc-cflags-before </del> echo "-idirafter ${libc_dev}${libc.incdir or "/include"}" >> $out/nix-support/libc-cflags '' + optionalString (isGNU && (!(cc.langD or false))) '' for dir in "${cc}"/lib/gcc/*/*/include-fixed; do

git ]; <del> # Workaround cc-wrapper's --sysroot= value for `staging-next`: it # breaks library lookup via RUNPATH: #   ld: warning: libm.so.6, needed by ./generated/linux/release/64/lib.so, not found (try using -rpath or -rpath-link) #   ld: /build/druntime/generated/linux/release/64/libdruntime.so: undefined reference to `log10@GLIBC_2.2.5' # TODO(trofi): remove the workaround once cc-wrapper is fixed. NIX_CFLAGS_COMPILE = [ "--sysroot=/" ]; </del> buildInputs = [ curl tzdata

NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [ "-fno-common" ] ++ lib.optionals enableOpenCL [ "-UPIPE_SEARCH_DIR" "-DPIPE_SEARCH_DIR="${placeholder "opencl"}/lib/gallium-pipe"" <del> # Work around regression from https://github.com/NixOS/nixpkgs/pull/210004 # TODO(trofi): remove "--sysroot=/" </del> ]; passthru = {

passAsFile = [ "extraConfig" ]; <del> # Workaround '-idirafter' ordering bug in staging-next: #   https://github.com/NixOS/nixpkgs/pull/210004 # where libc '-idirafter' gets added after user's idirafter and # breaks. # TODO(trofi): remove it in staging once fixed in cc-wrapper. preConfigure = '' export NIX_CFLAGS_COMPILE_BEFORE_${lib.replaceStrings ["-" "."] ["_" "_"] buildPackages.stdenv.hostPlatform.config}=$(< ${buildPackages.stdenv.cc}/nix-support/libc-cflags) export NIX_CFLAGS_COMPILE_BEFORE_${lib.replaceStrings ["-" "."] ["_" "_"]               stdenv.hostPlatform.config}=$(<               ${stdenv.cc}/nix-support/libc-cflags) ''; </del> configurePhase = '' runHook preConfigure

substituteInPlace src/util/genfsimg --replace "	syslinux " "	true " ''; # calling syslinux on a FAT image isn't going to work <del> # Workaround '-idirafter' ordering bug in staging-next: #   https://github.com/NixOS/nixpkgs/pull/210004 # where libc '-idirafter' gets added after user's idirafter and # breaks. # TODO(trofi): remove it in staging once fixed in cc-wrapper. preConfigure = '' export NIX_CFLAGS_COMPILE_BEFORE_${lib.replaceStrings ["-" "."] ["_" "_"] buildPackages.stdenv.hostPlatform.config}=$(< ${buildPackages.stdenv.cc}/nix-support/libc-cflags) export NIX_CFLAGS_COMPILE_BEFORE_${lib.replaceStrings ["-" "."] ["_" "_"]               stdenv.hostPlatform.config}=$(<               ${stdenv.cc}/nix-support/libc-cflags) ''; </del> # not possible due to assembler code hardeningDisable = [ "pic" "stackprotector" ];

sourceRoot = "source/src"; <del> # Workaround '-idirafter' ordering bug in staging-next: #   https://github.com/NixOS/nixpkgs/pull/210004 # where libc '-idirafter' gets added after user's idirafter and # breaks. # TODO(trofi): remove it in staging once fixed in cc-wrapper. preConfigure = '' export NIX_CFLAGS_COMPILE_BEFORE_${lib.replaceStrings ["-" "."] ["_" "_"] stdenv.hostPlatform.config}=$(< ${stdenv.cc}/nix-support/libc-cflags) ''; </del> buildInputs = [ libbfd zlib libiberty ]; makeFlags = [ "wimboot.x86_64.efi" ];