opencv-rust: Cannot install on Windows (syntax errors in common.hpp)

  1. Operating system

Windows 10

  1. The way you installed OpenCV: package, official binary distribution, manual compilation, etc.
choco install llvm opencv

Then manually set

OPENCV_DIR=C:\tools\opencv\build\x64\vc14\lib
OPENCV_INCLUDE_PATHS=C:\tools\opencv\build\include
OPENCV_LINK_LIBS=opencv_world412
OPENCV_LINK_PATHS=C:\tools\opencv\build\x64\vc15\lib
OPENCV_PATH=C:\tools\opencv

Also installed Universal CRT SDK through Visual Studio Installer and manually set additional environment variables:

INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include;D:\Windows Kits\10\Include\10.0.17763.0\ucrt;D:\Windows Kits\10\Include\10.0.17763.0\um;
LIB=D:\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64;D:\Windows Kits\10\Lib\10.0.17763.0\um\x64
  1. OpenCV version

4.1.2 (Also see the exact same issue with the 4.2.0 release from the OpenCV website)

  1. Attach the full output of the following command from your project directory:
$env:RUST_BACKTRACE="full"; cargo build -vv 

https://pastebin.com/USHHvZbw

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 38 (20 by maintainers)

Most upvoted comments

That’s quite weird, it looks like your version of cl.exe does not accept some code. As far as I can see the version used in CI works correctly.

Your compiler is:

C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX64\\x64\\cl.exe

The working one in CI:

C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.25.28610\\bin\\HostX64\\x64\\cl.exe

I’m not that familiar with the versioning of Visual Studio compilers, but it looks like it’s 2019 vs 2017. So can you please update to 2019 first and then try again?

The code that it rejects is struct initializer:

return Result_void { .error_code = 0, .error_msg = 0 };

It’s kind of weird that it’s ok with the similar code that is a couple of lines above it:

return Result<T> { .error_code = 0, .error_msg = 0, .result = result };