Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'limits' file not found #322

Open
AndreKR opened this issue Feb 15, 2022 · 24 comments
Open

'limits' file not found #322

AndreKR opened this issue Feb 15, 2022 · 24 comments

Comments

@AndreKR
Copy link

AndreKR commented Feb 15, 2022

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 #305 (comment) 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

@dirname
Copy link

dirname commented Feb 18, 2022

I think you should try OpenCV built with MinGW.

@AndreKR
Copy link
Author

AndreKR commented Feb 18, 2022

Yes, I agree. 😀 Where do I get that? I followed these instructions to install it.

@dirname
Copy link

dirname commented Feb 19, 2022

Yes, I agree. 😀 Where do I get that? I followed these instructions to install it.

You can try to build OpenCV from the source using CMake. Or try Mingw-w64 community triplets with vcpkg.

@foxzool
Copy link
Contributor

foxzool commented Mar 9, 2022

It's all fine when i use vs2019

but same issue appear after install vs2022

remove vs2022 everything is ok

@SteveCookTU
Copy link

Having the same issue. Seems as though standard c++ header files aren't being detected or rather it is trying to detect them over the standard c headers? I'm not really sure but I do know CLang is being passed in the standard c headers in the arguments based on the log. The issue doesn't seem to be actually building OpenCV (the libs and binaries are already built) but rather the parsing.

Would having a mingw installation fix the missing header files?

@LdDl
Copy link

LdDl commented Apr 14, 2022

It's all fine when i use vs2019

but same issue appear after install vs2022

remove vs2022 everything is ok

Thanks for reply
It worked for me too
(but I'm using 0.54 version currently, not 0.63 one)

@openmynet
Copy link

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

@python-101
Copy link

Hello,
I have the same issue with Ubuntu 22.
I tried everything i can.
It can't find limits and limits.h

Some infos..
my g++ --version => g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
my clang --version => Ubuntu clang version 14.0.0-1ubuntu1
my opencv_version => 4.6.0
In cargo.toml file => opencv => "0.76.2"

When i do cargo build =>
It find opencv...
=== OpenCV library configuration: Library {
include_paths: [
"/usr/local/include/opencv4",
],
version: Version {
major: 4,
minor: 6,
patch: 0,
},

But it fail => fatal error: 'limits' file not found

Any idea about what to do next to find the problem?

@twistedfall
Copy link
Owner

Can you please attach the full build log as produced by cargo build -vv?

@twistedfall
Copy link
Owner

I've created a fresh docker container from the Ubuntu-22.04 image and was able to build the project successfully with custom-built OpenCV 4.6.0. Here is my build log just in case: https://gist.github.com/twistedfall/8f03ac9a3ca35a9d0bf46ef87b7f8ec1

So it looks like the issue is not easily reproducible on Ubuntu-22.04, so if you could provide some more info about your system specifics it would help a lot.

@python-101
Copy link

Hi,
I am very happy.
On a fresh VM with Ubuntu-22.01, everything work fine!

Thanks for the fast reply!
rust_opencv

@twistedfall
Copy link
Owner

If you could still investigate what was wrong with the previous install it would really be helpful in tracking down the origin for this bug.

@twistedfall
Copy link
Owner

twistedfall commented Feb 2, 2023

Looks like this was the reason for this problem on Ubuntu 22.04: #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.

@Dmitry-Borodin
Copy link
Contributor

Same for me, libstdc++-12-dev fixed an issue. Maybe add in into crate readme?

@twistedfall
Copy link
Owner

Well, this only fixes it for this specific Ubuntu version under those specific (non-default) conditions, but adding a reference to this issue in general is a good idea.

@python-101
Copy link

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!

@Josha96
Copy link

Josha96 commented Feb 11, 2023

Was a fix found for this on windows using choco to install opencv and llvm ?

@twistedfall
Copy link
Owner

There were reports in this thread that installing different version of VS helped, otherwise please provide the full build log as produced by cargo build -vv, maybe I can find some pointers to solving your particular issue.

@JoaoCosme
Copy link

Looks like this was the reason for this problem on Ubuntu 22.04: #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.

This also worked for me on pop os 22.04, thanks!

@regwhitton
Copy link

apt install libstdc++-12-dev

Also solved it for me on Linux Mint 21.1

@mathletedev
Copy link

If anyone is running into this problem on NixOS, the clang package solved this issue for me.

@funlennysub
Copy link

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

Solution B seems to work but you have to run the script every time you restart the shell and also it doesn't fix this error message in rust analyzer.
I have clang 16.0.3 and opencv 4.8.1 from choco with all env vars set up
image

@brandonros
Copy link

On Mac, I accidentally was overriding clang from my .bash_profile with Android development related things:

#export ANDROID_HOME="/Users/brandon/Library/Android/sdk"
#export PATH="/Users/brandon/Library/Android/sdk/emulator:$PATH"
#export PATH="/Users/brandon/Library/Android/sdk/platform-tools:$PATH"
#export PATH="/Users/brandon/Library/Android/sdk/cmdline-tools/latest/bin:$PATH"
#export PATH="/Users/brandon/Library/Android/sdk/build-tools/34.0.0:$PATH"
#export PATH="/Users/brandon/Library/Android/sdk/ndk/25.2.9519653:$PATH"
#export PATH="/Users/brandon/Library/Android/sdk/cmake/3.22.1/bin:$PATH"
#export PATH="/Users/brandon/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin:$PATH"

I found this out by running which clang and which gcc (having some covered by brew, some covered by xcode-select caused for confusion/collision)

Hopefully this helps somebody else!

@openmynet
Copy link

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

Solution B seems to work but you have to run the script every time you restart the shell and also it doesn't fix this error message in rust analyzer. I have clang 16.0.3 and opencv 4.8.1 from choco with all env vars set up image

  1. copy Solution B to %USERPROFILE%\Documents\WindowsPowerShell\profile.ps1
  2. Restart vscode or powershell
  3. fix this error message in rust analyzer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests