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:

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 (Edit: I removed the extra MinGW from my system and the error is the same.)nightly-x86_64-pc-windows-gnu toolchain brings its own tools and does not use a potentially installed MinGW installation.
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.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 24 (8 by maintainers)
Looks like this was the reason for this problem on Ubuntu 22.04: https://github.com/twistedfall/opencv-rust/issues/419
In short,
libclangpicks up libstdc+±12 headers, probably because of previously installedgcc-12(which doesn’t install the corresponding libstdc++ headers), so the system only had libstdc++ headers from gcc-11 installed. Installinglibstdc++-12-devfixes 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:
Developer Command Prompt for VS 2019orDeveloper PowerShell for VS 2019cd path/to/projectopencv_world4xx.dll .. opencv**.dlltotarget/debugcargo runB: vcenv.ps1
run
It’s all fine when i use vs2019
but same issue appear after install vs2022
remove vs2022 everything is ok