opencv-rust: 'limits' file not found

I tried building an application with opencv but it fails to build.

Toolchain:

nightly-x86_64-pc-windows-gnu (default)
rustc 1.59.0-nightly (c5ecc1570 2021-12-15)

Naively I ran cargo build but I got an error could not execute llvm-config. So I went back to read the README and it instructed me to run choco install llvm opencv.

I also preemptively set these environment variables because I read they were needed: image

Then I got cannot find -lclang.dll. Following https://github.com/twistedfall/opencv-rust/issues/305#issuecomment-1034002638 I downloaded llvm-cumMinGW-x86_64-w64-mingw32-posix-msvcrt-v1.0.0.7z from here, extracted it and added llvm-cumMinGW64-msvcrt\lib and llvm-cumMinGW64-msvcrt\bin to my PATH.

I got an error, something about vcruntime_exception.h and I noticed that the build process now used binaries from llvm-cumMinGW64-msvcrt\bin, so I removed it again from PATH and instead, as the issue comment suggests, I copied libclang.dll.a to C:\dev-tools\Rust\.multirust\toolchains\nightly-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib.

The reason I chose this folder is that I saw it being used in the error message. I’m actually a bit surprised to see it being used because I was quite sure that the nightly-x86_64-pc-windows-gnu toolchain brings its own tools and does not use a potentially installed MinGW installation. (Edit: I removed the extra MinGW from my system and the error is the same.)

Anyway, the next error that I now get is fatal error: 'limits' file not found and I had no luck finding a solution for that.

Full build log

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 24 (8 by maintainers)

Most upvoted comments

Looks like this was the reason for this problem on Ubuntu 22.04: https://github.com/twistedfall/opencv-rust/issues/419

In short, libclang picks up libstdc+±12 headers, probably because of previously installed gcc-12 (which doesn’t install the corresponding libstdc++ headers), so the system only had libstdc++ headers from gcc-11 installed. Installing libstdc++-12-dev fixes the issue.

Hi, I just install the “libstdc+±12-dev” package on my Ubuntu 22.04.1 LTS laptop and it solves my problem. No more fatal error: ‘limits’ file not found. You rock!

Thanks again for your help!

Having the same issue. I solved the problem after entering the VC compilation environment. A:

  1. open Developer Command Prompt for VS 2019 or Developer PowerShell for VS 2019
  2. cd path/to/project
  3. copy opencv_world4xx.dll .. opencv**.dll to target/debug
  4. cargo run

B: vcenv.ps1

$vsPath="C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional"
Import-Module ("$vsPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
# -arch=x64 -host_arch=x64
# -arch=x86 -host_arch=x86
Enter-VsDevShell -VsInstallPath "$vsPath"  -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64"

run

./vcenv.ps1
cargo run

It’s all fine when i use vs2019

but same issue appear after install vs2022

remove vs2022 everything is ok