Skip to content

opencv 4.7.0 in nixpkgs master has link errors  #214124

@tfc

Description

@tfc

Describe the bug

Hi, I created a minimal demonstrator for my problem:
https://github.com/tfc/whiteboard-opencv/tree/without-aruco (not main branch but without-aruco, to also build with nixos 22.11)

This minimal C++ app includes and links against opencv4.

Building this flake using nix build works just fine and the resulting app works.
Running nix develop and then doing mkdir build && cd build && cmake .. && make results in link errors:

... many others omitted ...
nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: /nix/store/g8lrv5d3ixb2gmyhl14wkb6jl7wnqadc-opencv-4.7.0/lib/libopencv_core.so.4.7.0: undefined reference to `omp_get_max_threads@OMP_1.0'
/nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: /nix/store/g8lrv5d3ixb2gmyhl14wkb6jl7wnqadc-opencv-4.7.0/lib/libopencv_videoio.so.4.7.0: undefined reference to `gst_caps_set_simple'
/nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: /nix/store/g8lrv5d3ixb2gmyhl14wkb6jl7wnqadc-opencv-4.7.0/lib/libopencv_core.so.4.7.0: undefined reference to `clCreateCommandQueue@OPENCL_1.0'
/nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: /nix/store/g8lrv5d3ixb2gmyhl14wkb6jl7wnqadc-opencv-4.7.0/lib/libopencv_dnn.so.4.7.0: undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::RemoveLast()'
/nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: /nix/store/g8lrv5d3ixb2gmyhl14wkb6jl7wnqadc-opencv-4.7.0/lib/libopencv_videoio.so.4.7.0: undefined reference to `avcodec_get_context_defaults3@LIBAVCODEC_58'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/DisplayImage.dir/build.make:107: DisplayImage] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/DisplayImage.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

With nixpkgs on 22.11, both nix build and nix develop work.

Steps To Reproduce

Steps to reproduce the behavior:

  1. check out reproducer repo
  2. Run nix build, works
  3. Enter nix shell using nix develop and run: mkdir build && cd build && cmake .. && make, get mentioned error messages
  4. Change flake input to nixpkgs 22.11
  5. Repeat step 1 & 2 and see that they work

Expected behavior

I would expect to not get these linker errors after upgrading to nixpkgs master

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Notify maintainers

@mdaiter @basvandijk

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.90, NixOS, 22.11 (Raccoon)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.1`
 - channels(root): `"home-manager-21.11.tar.gz, nixos-21.11, nixos-unstable"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions